Inventry.java 719B

123456789101112131415161718192021222324252627282930313233
  1. import java.util.*;
  2. public class Inventry
  3. {
  4. private ArrayList<Product> products;
  5. private int totalQuantity;
  6. public Inventry(ArrayList<Product> products){
  7. this.products = products;
  8. }
  9. public ArrayList<Product> getInventry(){
  10. return products;
  11. }
  12. public void addToInventry(Product product){
  13. products.add(product);
  14. totalQuantity += product.getQuantity();
  15. }
  16. public void removeFromInventry(Product product){
  17. products.remove(product);
  18. totalQuantity -= product.getQuantity();
  19. }
  20. public int getSize(){
  21. return products.size();
  22. }
  23. public int getTotalQuantity(){
  24. return totalQuantity;
  25. }
  26. }