MainApplication.java 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package com.zipcodewilmington.productmanager;
  2. import java.sql.SQLOutput;
  3. import java.util.Scanner;
  4. import java.util.*;
  5. /**
  6. * Created by leon on 1/10/18.
  7. */
  8. public class MainApplication {
  9. private static int id = 6;
  10. public static void main(String[] args) {
  11. Product jacket = new Product("Jacket", 1, 29.99, 5);
  12. Product hat = new Product("Hat", 2, 9.99, 15);
  13. Product shirt = new Product("Shirt", 3, 14.99, 10);
  14. Product pants = new Product("Pants", 4, 19.99, 10);
  15. Product shoes = new Product("Shoes", 5, 29.99, 5);
  16. Scanner scan = new Scanner(System.in);
  17. int toDo = 0;
  18. while (toDo != 8) {
  19. System.out.println("What would you like to do?");
  20. System.out.println("Type '1' to ADD a product");
  21. System.out.println("Type '2' to REMOVE a product");
  22. System.out.println("Type '3' to FIND a product by ID");
  23. System.out.println("Type '4' to FIND a product by NAME");
  24. System.out.println("Type '5' to ADD a QUANTITY to the Inventory");
  25. System.out.println("Type '6' to REMOVE a QUANTITY to the Inventory");
  26. System.out.println("Type '7' to PRINT list of inventory");
  27. System.out.println("Type '8' to QUIT");
  28. toDo = scan.nextInt();
  29. Inventory invent = new Inventory();
  30. switch (toDo) {
  31. case 1:
  32. id++;
  33. System.out.println("What is the NAME of the PRODUCT would you like to ADD?");
  34. String addProduct = scan.next();
  35. System.out.println("What is the PRICE of the " + addProduct + "?");
  36. Double addProductPrice = scan.nextDouble();
  37. System.out.println("What is the QUANTITY of " + addProduct + " that you would like to add?");
  38. int addProductQuantity = scan.nextInt();
  39. System.out.println("PRODUCT\tID\tQUANITY\tPRICE\t");
  40. System.out.println(addProduct + "\t" + id + "\t" + addProductQuantity + "\t\t" + addProductPrice);
  41. Product product = new Product(addProduct, id, addProductPrice, addProductQuantity);
  42. break;
  43. case 2:
  44. id--;
  45. System.out.println("How would you like to remove the product?");
  46. System.out.println("Type '1' to REMOVE by ID:");
  47. System.out.println("Type '2' to REMOVE by NAME:");
  48. int howToRemove = scan.nextInt();
  49. if (howToRemove == 1) {
  50. System.out.println("What is the ID of the product to be REMOVED?");
  51. int idToRemove = scan.nextInt();
  52. invent.list.remove(idToRemove);
  53. } else {
  54. System.out.println("What is the NAME of the product to be REMOVED?");
  55. String nameToRemove = scan.next();
  56. invent.list.remove(nameToRemove);
  57. }
  58. break;
  59. case 3:
  60. System.out.println("What is the ID of the product?");
  61. int idToFind = scan.nextInt();
  62. invent.findProductById(idToFind);
  63. System.out.println("PRODUCT\tID\tQUANITY\tPRICE\t");
  64. // System.out.println(addProduct + "\t" + id + "\t" + addProductQuantity + "\t\t" + addProductPrice);
  65. break;
  66. case 4:
  67. System.out.println("What is the NAME of the product?");
  68. String nameToFind = scan.next();
  69. invent.findProductByName(nameToFind);
  70. System.out.println("PRODUCT\tID\tQUANITY\tPRICE\t");
  71. // System.out.println(addProduct + "\t" + id + "\t" + addProductQuantity + "\t\t" + addProductPrice);
  72. break;
  73. case 5:
  74. System.out.println("What product do you want to add to?");
  75. nameToFind = scan.next();
  76. System.out.println("How many " + nameToFind + "'s do you want to add?");
  77. int totalToAdd = scan.nextInt();
  78. invent.addQuantity(nameToFind, totalToAdd);
  79. break;
  80. case 6:
  81. break;
  82. case 7:
  83. invent.printInventory();
  84. break;
  85. }
  86. }
  87. }
  88. }