123456789101112131415161718192021222324252627282930 |
- import java.util.*;
-
- /**
- * Write a description of class Inventory here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class Inventory
- {
- List<Product> productList = new ArrayList<Product>();
-
- public void addProductToInventory(Product product)
- {
- productList.add(product);
- }
-
- public Product[] getInventory(){
- return this.productList.toArray(new Product[productList.size()]);
- }
-
- public double sumInventoryValue(){
- double sum = 0;
- for (Product p : this.productList){
- sum += p.getPrice()*p.getQuantity();
- }
- return sum;
- }
- }
|