Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.60 KB | None | 0 0
  1.  while (!response.equals("stop")) {
  2.                 System.out.println("\n\nWhat do you want to do? You can type 'manual' to add a record manually, " +
  3.                         "'reset' to reset the passengers and schedules tables or 'file' to load records from a " +
  4.                         "file. Type 'stop' to exit. Do not type the quotations");
  5.                 response = input.nextLine();
  6.  
  7.                 switch (response) {
  8.                     case "manual":
  9.                         String resp = "";
  10.                         while(true) {
  11.                             System.out.println("What is the passenger information you want to load in? The format to " +
  12.                                     "input a passenger record is 'P TUID First_Initial Middle_Initial Last_Name " +
  13.                                     "Phone_Number'. Type stop to back out");
  14.                             System.out.println();
  15.                             resp = input.nextLine();
  16.                             if(resp.equals("stop")){
  17.                                 break;
  18.                             }
  19.                             insertIntoPassenger(resp, state);
  20.  
  21.                             System.out.println("What is the schedule information you want to load in? The format to " +
  22.                                     "input schedule information S Customer_TUID Requested_Plane_TUID " +
  23.                                     "Requested_Seating_Type Requested_Date:");
  24.                             System.out.println();
  25.                             resp = input.nextLine();
  26.                             if(resp.equals("stop")){
  27.                                 break;
  28.                             }
  29.                             insertIntoScheduleTable(resp);
  30.                         }
  31.  
  32.                         break;
  33.                     case "reset":
  34.                         DBClass.tableReset();
  35.                         break;
  36.                     case "file":
  37.                         System.out.println("What is the name of the file you want to load in. Example: 'sample.txt' without the quotations");
  38.                         Scanner sc = new Scanner(new File(input.next()));
  39.  
  40.                         while (sc.hasNextLine()) {
  41.                             String line = sc.nextLine();
  42.                             if (line.charAt(0) == 'P') {
  43.                                 insertIntoPassenger(line, state);
  44.                             } else if (line.charAt(0) == 'S') {
  45.                                 insertIntoScheduleTable(line);
  46.                             }
  47.                         }
  48.                         break;
  49.  
  50.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement