123456789101112131415161718192021222324252627
  1. import java.util.*;
  2. public class Inventory{
  3. private List<Product> products;
  4. public Inventory(){
  5. products = new ArrayList();
  6. }
  7. public void add(Product product){
  8. products.add(product);
  9. }
  10. public List<Product> getProducts(){
  11. return products;
  12. }
  13. public int getTotalQuantity(){
  14. int total = 0;
  15. for(Product p : products){
  16. total = total + p.getQuantityOfItem();
  17. }
  18. return total;
  19. }
  20. }