Inventory.java 706B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * Write a description of class Inventory here.
  3. *
  4. * @author (your name)
  5. * @version (a version number or a date)
  6. */
  7. public class Inventory
  8. {
  9. private Product[] product;
  10. private double inventoryValue = 0;
  11. public Inventory(Product[] product){
  12. this.product = product;
  13. }
  14. public double getWholeInventoryValue(Product[] product){
  15. for (Product element : product){
  16. inventoryValue += (getValueOfAProduct(element));
  17. }
  18. return inventoryValue;
  19. }
  20. public double getValueOfAProduct(Product product){
  21. double price = product.getPrice();
  22. int quantity = product.getQuantity();
  23. return price*quantity;
  24. }
  25. }