12345678910111213141516171819202122232425262728293031 |
- import java.util.ArrayList;
-
- public class Inventory
- {
-
- private ArrayList<Product> products;
-
- public Inventory(){
- products = new ArrayList<>();;
- }
-
- public void add(Product product){
- products.add(product);
- }
-
- public String getAllProductInfo(){
- String info = "";
- for (Product element: products){
- info += "Product: " + element.getName() + "\nProduct ID: " + element.getId() + "\nPrice: " + element.getPrice() + "\nQuantity: " + element.getQuantity() + "\nValue: " + element.getValue() + "\n****************\n";
- }
- return info;
- }
-
- public double getTotalInventoryValue(){
- double total = 0;
- for(Product element: products){
- total += element.getValue();
- }
- return total;
- }
- }
|