MainApplication.java 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import java.util.Scanner;
  2. /**
  3. * Created by leon on 1/10/18.
  4. */
  5. public class MainApplication {
  6. public static void main(String[] args) {
  7. Scanner warehouse = new Scanner(System.in);
  8. Inventory inventory = new Inventory();
  9. inventory.add(new Product("Sony Playstation", 400, 100));
  10. inventory.add(new Product("Microsoft Xbox", 500, 200));
  11. inventory.add(new Product("Nintendo Switch", 400, 300));
  12. System.out.println("Name the product you want to find.");
  13. System.out.println("1.)Xbox" + "\n" + "2.)Playstation" + "\n" + "3.)Nintendo");
  14. String next = warehouse.nextLine();
  15. switch(next){
  16. case "2":
  17. System.out.print(inventory.find("Sony Playstation"));
  18. break;
  19. case "1":
  20. System.out.println(inventory.find("Microsoft Xbox"));
  21. break;
  22. case "3":
  23. System.out.print(inventory. find("Nintendo Switch"));
  24. break;
  25. }
  26. System.out.println("Choose which product to get the total price.");
  27. System.out.println("1.)Xbox" + "\n" + "2.)Playstation" + "\n" + "3.)Nintendo");
  28. String again = warehouse.next();
  29. switch(again) {
  30. case "2":
  31. System.out.print(inventory.getTotalPrice("Sony Playstation"));
  32. warehouse.nextLine();
  33. break;
  34. case "1":
  35. System.out.println(inventory.getTotalPrice("Microsoft Xbox"));
  36. warehouse.nextLine();
  37. break;
  38. case "3":
  39. System.out.print(inventory.getTotalPrice("Nintendo Switch"));
  40. warehouse.nextLine();
  41. break;
  42. }
  43. }
  44. }