Manager.java 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * Write a description of class Manager here.
  3. *
  4. * @author (your name)
  5. * @version (a version number or a date)
  6. */
  7. public class Manager
  8. {
  9. Console aConsole = new Console();
  10. Inventory inventory = new Inventory();
  11. Product aProduct;
  12. public void createInventory(){
  13. int numberOfProducts = aConsole.userSetNumberOfProducts();
  14. for (int i = 0; i < numberOfProducts; i++){
  15. inventory.addProductToInventory(aProduct = new Product(aConsole.userSetName(),
  16. aConsole.userSetPrice(), aConsole.userSetID(), aConsole.userSetQuantity()));
  17. }
  18. }
  19. public void recordInventory(){
  20. Product[] allProducts = inventory.getInventory();
  21. System.out.println("Products in inventory: ");
  22. for (Product p : allProducts){
  23. System.out.println("#" + p.getID() + " " + p.getName() + " $" +
  24. p.getPrice() + " " + p.getQuantity() + "qty");
  25. }
  26. double sumOfValue = inventory.sumInventoryValue();
  27. System.out.println("The value of all inventory is: $" + sumOfValue);
  28. }
  29. }