12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import java.util.Scanner;
-
- /**
- * Created by leon on 1/10/18.
- */
- public class MainApplication {
-
- public static void main(String[] args) {
- Scanner warehouse = new Scanner(System.in);
- Inventory inventory = new Inventory();
- inventory.add(new Product("Sony Playstation", 400, 100));
- inventory.add(new Product("Microsoft Xbox", 500, 200));
- inventory.add(new Product("Nintendo Switch", 400, 300));
-
- System.out.println("Name the product you want to find.");
- System.out.println("1.)Xbox" + "\n" + "2.)Playstation" + "\n" + "3.)Nintendo");
- String next = warehouse.nextLine();
-
-
-
- switch(next){
- case "2":
- System.out.print(inventory.find("Sony Playstation"));
-
- break;
- case "1":
- System.out.println(inventory.find("Microsoft Xbox"));
-
- break;
- case "3":
- System.out.print(inventory. find("Nintendo Switch"));
-
- break;
- }
-
- System.out.println("Choose which product to get the total price.");
- System.out.println("1.)Xbox" + "\n" + "2.)Playstation" + "\n" + "3.)Nintendo");
- String again = warehouse.next();
- switch(again) {
- case "2":
- System.out.print(inventory.getTotalPrice("Sony Playstation"));
- warehouse.nextLine();
- break;
- case "1":
- System.out.println(inventory.getTotalPrice("Microsoft Xbox"));
- warehouse.nextLine();
- break;
- case "3":
- System.out.print(inventory.getTotalPrice("Nintendo Switch"));
- warehouse.nextLine();
- break;
- }
- }
- }
|