Advertisement
UKTC162

App

Jan 22nd, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.62 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4. public class App {
  5.  
  6.     public static void main(String[] args) {
  7.  
  8.         Scanner sc = new Scanner(System.in);
  9.  
  10.         Car c1 = new Car("Ford", "Mustang", 2010, 10000.0, 1);
  11.         Car c2 = new Car("Renault", "Megan", 2005, 20000.0, 2);
  12.         ArrayList<Car> cars = new ArrayList<Car>();
  13.         cars.add(c1);
  14.         cars.add(c2);
  15.  
  16.         CarDealer carDealer = new CarDealer("Cars inc.", "Here", "Me", 5000.0, 10, cars);
  17.  
  18.         // App starts
  19.         while (true) {
  20.             System.out.printf("-----------------------------------%n"
  21.                     + "If you are a customer type 1.%nIf you are an administrator type 2.%n");
  22.             String cOrA = sc.nextLine();
  23.             if (cOrA.equals("1")) {
  24.                 System.out.printf("Choose:%nLook at cars(1);%nBuy a car(2);%n");
  25.                 int choiceC = Integer.parseInt(sc.nextLine());
  26.                 switch (choiceC) {
  27.                 case 1:
  28.                     CarDealer.ListInfo();
  29.                     break;
  30.                 case 2:
  31.                     CarDealer.sellCar();
  32.                     break;
  33.                 default:
  34.                     System.out.println("Try again.");
  35.                 }
  36.             } else if (cOrA.equals("2")) {
  37.                 System.out.printf("Choose:%nLook at cars(1);%nAdd a car(2);"
  38.                         + "%nRemove a car(3);%nUpdate a car(4);%nSee budget(5);%n");
  39.                 int choiceA = Integer.parseInt(sc.nextLine());
  40.                 switch (choiceA) {
  41.                 case 1:
  42.                     CarDealer.ListInfo();
  43.                     break;
  44.                 case 2:
  45.                     CarDealer.addCar();
  46.                     break;
  47.                 case 3:
  48.                     CarDealer.removeCar();
  49.                     break;
  50.                 case 4:
  51.                     CarDealer.updateCar();
  52.                     break;
  53.                 case 5:
  54.                     CarDealer.infoBudget();
  55.                     break;
  56.                 default:
  57.                     System.out.println("Try again.");
  58.                 }
  59.             } else {
  60.                 System.out.println("Please try again.");
  61.             }
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement