Commit 87456b4d authored by daniel.tang's avatar daniel.tang

Assignment

parent 734cd8d6
package airline_reservation_system;
import java.lang.reflect.Array; // not in use....
import java.util.Scanner;
import java.util.ArrayList;
class assessment_part_1 {
static Scanner input = new Scanner(System.in); // LIKE OOP BUT NOT BULLSHIT WITH LONG ASS CODING IN C#
// without static it I would have to copy & paste the Scanner to all voids
static int x, y; // allow to use all without copy & paste & waste of time ez pz
// Arrays
static ArrayList<String> firstName = new ArrayList<String>();
static ArrayList<String> lastName = new ArrayList<String>();
static ArrayList<String> origin = new ArrayList<String>();
static ArrayList<String> destination = new ArrayList<String>();
static ArrayList<String> seatBook = new ArrayList<String>();
static ArrayList<String> travelingClass = new ArrayList<String>();
static ArrayList<String> choosenFlight = new ArrayList<String>();
static ArrayList<String> boardName = new ArrayList<String>();
static ArrayList<String> boardLast = new ArrayList<String>();
static ArrayList<String> boardOrigins = new ArrayList<String>();
static ArrayList<String> boardDestination = new ArrayList<String>();
static ArrayList<String> boardseatBook = new ArrayList<String>();
static ArrayList<String> travelsClass = new ArrayList<String>();
static ArrayList<String> boardFlight = new ArrayList<String>();
// Errm Buisness & Ecom are BROKEN.... BROKEN Code....
public static void main(String[] args) {
// Something that I'm wasting space pepegas
firstName.add("Daniel");
lastName.add("Tang");
origin.add("Hong Kong");
destination.add("Somewhere in Japan due to protest");
seatBook.add("101");
travelingClass.add("First");
// Interface
while(true) {
System.out.print("Enter 'F' for displaying avaliable flight OR enter 'C' to book a flight > ");
String user = input.next();
if(user.equals("F")) {
flightAvaliable(); // Display flight
}
else if(user.equals("C"))
booking(); // Booking flight
System.out.println();
System.out.println();
}
} // Main end
private static void flightAvaliable() { // Flight display
int l = 28; // from 28
do {
System.out.println("FL-" + l); //
l--;
} while(l > 1);
System.out.println();
// add a flight number where the person sees it however the user need to input Flight so it can be recalled to the boarding pass...
} // Flight display end
private static void booking() { // Booking <
System.out.println();
System.out.println("Welcome to airline booking reservation");
System.out.println();
// Shows menu
while(true) { // While true comment out because it loop unncessary
// Menu
System.out.println("Please enter > \n"
+" \n"
+"O - Name \n"
+"T - Travel Class \n" // Travel Class > seating > checked
+"P - Flight \n"
+"K - Check Boarding Pass \n"
+"OR type 'Exit' to exit the application. \n"
+" \n"
+"Note: This is case sensitive, please enter in caps. \n"
+"");
String customerChoice = input.next(); // Customer choice on travel class
switch(customerChoice) {
case "O":
nameSwitch();
break;
case "T":
travelSwitch();
break;
case "P":
flightSwitch();
break;
case "K":
boardingSwitch();
break;
case "M":
managementRole();
break;
case "Exit":
return;
default:
System.out.print("Invalid input, please try again");
System.out.println();
System.out.println();
System.out.println();
} // End Switch Case
} // End while loop
} // Booking end
// nameSwitch
public static void nameSwitch() {
System.out.print("Please enter your first name > ");
String firstName = input.next(); // firstname = ID CAP SPECIFIC
System.out.println();
System.out.print("Please enter your last name > ");
String lastName = input.next(); // lastname = ID CAP SPECIFIC
System.out.println();
System.out.print("Please enter your origin > ");
String origin = input.next(); // origin = ID CAP SPECIFIC
System.out.println();
System.out.print("Please enter your destination > ");
String destination = input.next(); // origin = ID CAP SPECIFIC
System.out.println();
// To storage???? > Local till program kms
boardName.add(firstName);
boardLast.add(lastName);
boardOrigins.add(origin);
boardDestination.add(destination);
//travelsClass.add(travelsClass);
//boardClassfirst.add(Classfirst);
}
// travelSwitch >>> another switch case >>> each travel class has its own seat arrangement
public static void travelSwitch() {
// Menu
//while(true) {
System.out.println("Please enter your travel class \n"
+" \n"
+"First - First Class \n"
+"Business - Buisness Class \n" // Travel Class > seating > checked
+"Economy - Economy Class \n"
+"OR type 'Exit' to exit the application. \n"
+" \n"
+"Note: This is case sensitive, please type 'First' enter First class, ect \n"
+"");
String travelingClass = input.next();
travelsClass.add(travelingClass);
String travelChoice = input.next(); // Customer choice on travel class
switch(travelChoice) { // Switch case
case "First":
firstClass(); // Goes to public class >>>>
break;
case "Business":
businessClass();
break;
case "Economy":
economyClass();
break;
//case "Exit":
//return;
default:
System.out.print("Invalid input, please try again");
System.out.println();
System.out.println();
System.out.println();
} // End Switch Case
//} // End while loop
} // end travelClass
// firstClass
public static void firstClass() {
//Scanner input = new Scanner(System.in);
//int x, y;
System.out.println();
System.out.print("Please enter your seat > ");
System.out.println("");
System.out.println("Note if you want seats 1 - 9, please enter,"
+ "0 1 to have seat 1.");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("FIRST CLASS");
String board1[][] = {{"", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}, // Allow user to type in 01 instead of
{"", "[01]", "[02]", "[03]", "|", "[04]", "[05]", "[06]", "|", "[07]", "[08]", "[09]"}, // 00 to present as 01
{"", "[10]", "[11]", "[12]", "|", "[13]", "[14]", "[15]", "|", "[16]", "[17]", "[18]"}, // | represent hallways
{"", "----", "----", "----", "+", "----", "----", "----", "+", "----", "----", "----"}}; // ---- represent Galleys
display1(board1);
System.out.println("");
System.out.println("Enter > ");
String seatBook = input.next(); // This allow store this specific string/data temp until the program crash
System.out.println();
System.out.print("");
boardseatBook.add(seatBook); // make it easier for boarding class.
x = input.nextInt();
y = input.nextInt();
board1[x][y] = "[XX]";
while(true) {
if(board1[x][y] == "[XX]") { // if user type 0 3 it will break ????
break; }
}
System.out.print("Seat: " + seatBook);
display1(board1);
} // end firstclass board1
public static void display1(String board1[][]) { // Displays board
for(int i=0; i<3; i++) { // Columns
for(int j=0; j<12; j++) { // Rows
System.out.print( board1[i][j] + "");
}
System.out.println();
}
} // End display
public static boolean bookedSeats1(String a, String board1[][]) { // Conditions if first class is fully booked...
if( a.equals((board1[0][1] + board1[0][2] + board1[0][3] + board1[0][4] + board1[0][5] + board1[0][6] + board1[0][7] + board1[0][8] + board1[0][9] + board1[0][10] + board1[0][11] + board1[0][12])) || // 1 This is the condition...
a.equals((board1[1][2] + board1[1][2] + board1[1][3] + board1[1][4] + board1[1][5] + board1[1][6] + board1[1][7] + board1[1][8] + board1[1][9] + board1[1][10] + board1[1][11] + board1[1][12]))) // 2
return true;
else
return false;
} // end for firstClass boolean
// boardingSwitch >>> goes to the boarding pass, however need certain conditions to go forward....
public static void boardingSwitch() {
System.out.println("|[ BOARDING PASS ] | \n"
+"| | \n"
+"| Name: " + boardName + boardLast + " | \n" //"Name: + from Array + array "
+"| Origin: " + boardOrigins + " | \n"
+"| Destination: " + boardDestination + " | \n"
+"| Flight: " + boardFlight +" | \n" // Flight doesn't work because i didn't link
+"| Travel Class: " + travelsClass + " Class | \n"
+"| Seating Plan: " + boardseatBook + " | \n"
+"");
}
// buisnessClass
public static void businessClass() {
//Scanner input = new Scanner(System.in);
//int x, y;
System.out.println();
System.out.print("To enter your seat > ");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("BUISNESS CLASS");
String board2[][] = {{"", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}, // Allow user to type in 01 instead of
{"", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}, // 1 - 9
{"", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}, //Seat 10 - 18
{"", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}, // Galleys
{"", "[19]", "[20]", "[21]", "|", "[22]", "[23]", "[24]", "|", "[25]", "[26]", "[27]"}, // 00 to present as 01
{"", "[28]", "[29]", "[30]", "|", "[31]", "[32]", "[33]", "|", "[34]", "[35]", "[36]"}, // | represent hallways
{"", "[37]", "[38]", "[39]", "|", "[40]", "[41]", "[42]", "|", "[43]", "[44]", "[45]"},
{"", "----", "----", "----", "+", "----", "----", "----", "+", "----", "----", "----"}}; // ---- represent Galleys
display2(board2);
System.out.println("");
System.out.println("Enter > ");
String seatBook = input.next();
System.out.println();
System.out.print("");
boardseatBook.add(seatBook);
x = input.nextInt();
y = input.nextInt();
board2[x][y] = "[XX]";
while(true) {
if(board2[x][y] == "[XX]") { // if user type 0 3 it will break
board2[x][y] = " ";
break; }
}
System.out.print("Seat: " + seatBook);
display2(board2);
}
// display2
public static void display2(String board2[][]) { // Displays board
for(int g=0; g<8; g++) { // Columns
for(int f=0; f<12; f++) { // Rows
System.out.print( board2[g][f] + ""); // print out board 2
}
System.out.println();
}
} // End display
// boolean check for "booked"
public static boolean bookedSeats2(String j, String board2[][]) { // Conditions if buiness class is fully booked...
if( j.equals((board2[9][1] + board2[9][2] + board2[9][3] + board2[9][4] + board2[9][5] + board2[9][6] + board2[9][7] + board2[9][8] + board2[9][9] + board2[9][10] + board2[9][11] + board2[9][12] )) ||
j.equals((board2[10][1] + board2[10][2] + board2[10][3] + board2[10][4] + board2[10][5] + board2[10][6] + board2[10][7] + board2[10][8] + board2[10][9] + board2[10][10] + board2[10][11] + board2[10][12])) ||
j.equals((board2[11][1] + board2[11][2] + board2[11][3] + board2[11][4] + board2[11][5] + board2[11][6] + board2[11][7] + board2[11][8] + board2[11][9] + board2[11][10] + board2[11][11] + board2[10][12]))) // 2
return true;
else
return false;
} // end buisnessClas
// managementRole
private static void managementRole() {
System.out.println("Name--|--Last--|--Ori--|--Dest--|--Class--|--Seat--|--Plane");
int size = boardName.size();
for(int i=0; i < size; i++) {
System.out.println(boardName.get(i) + "\t" +
boardLast.get(i) + "\t" +
boardOrigins.get(i) + "\t" +
boardDestination.get(i) + "\t" +
travelsClass.get(i) + "\t" +
boardseatBook.get(i) + "\t" +
boardFlight.get(i) );
System.out.println("--------------------------------");
}
} // end managementRoles
// economyClass
public static void economyClass() {
//Scanner input = new Scanner(System.in);
int x, y;
System.out.println();
System.out.print("To enter your seat > ");
System.out.println("");
System.out.println("");
System.out.println("");
System.out.println("ECONOMY CLASS");
String board3[][] = {{"", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}, // Allow user to type in 01 instead of 00 for seat 1
{"", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
{"", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
{"", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
{"", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
{"", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}, //Seat 10 - 18
{"", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
{"", "----", "----", "----", "+", "----", "----", "----", "+", "----", "----", "----"},
{"", "[46]", "[47]", "[48]", "|", "[49]", "[50]", "[51]", "|", "[52]", "[53]", "[54]"}, // 00 to present as 01
{"", "[55]", "[56]", "[57]", "|", "[58]", "[59]", "[60]", "|", "[61]", "[62]", "[63]"}, // | represent hallways
{"", "[64]", "[65]", "[66]", "|", "[67]", "[68]", "[69]", "|", "[70]", "[71]", "[72]"},
{"", "[73]", "[74]", "[75]", "|", "[76]", "[77]", "[78]", "|", "[79]", "[80]", "[81]"}, // 00 to present as 01
{"", "[82]", "[83]", "[84]", "|", "[85]", "[86]", "[87]", "|", "[88]", "[89]", "[90]"}, // | represent hallways}; // ---- represent Galleys
{"", "----", "----", "----", "+", "----", "----", "----", "+", "----", "----", "----"}};
display3(board3);
System.out.println("");
System.out.println("Enter > ");
String seatBook = input.next();
System.out.println();
System.out.print("");
//boardseatBook.add(seatBook); // USELESS
x = input.nextInt();
y = input.nextInt();
board3[x][y] = "[XX]";
while(true) {
if(board3[x][y] == "[XX]") { // if user type 0 3 it will break
board3[x][y] = " ";
break; }
}
System.out.print("Seat: " + seatBook);
display3(board3);
}
public static void display3(String board3[][]) { // Displays board
for(int q=0; q<14; q++) { // Columns
for(int w=0; w<12; w++) { // Rows
System.out.print( board3[q][w] + "");
}
System.out.println();
}
} // End display
public static boolean bookedSeats3(String x, String board3[][]) { // Conditions if eco class is fully booked...
if( x.equals((board3[9][1] + board3[9][2] + board3[9][3] + board3[9][4] + board3[9][5] + board3[9][6] + board3[9][7] + board3[9][8] + board3[9][9] + board3[9][10] + board3[9][11] + board3[9][12] )) ||
x.equals((board3[10][1] + board3[10][2] + board3[10][3] + board3[10][4] + board3[10][5] + board3[10][6] + board3[10][7] + board3[10][8] + board3[10][9] + board3[10][10] + board3[10][11] + board3[10][12])) ||
x.equals((board3[11][1] + board3[11][2] + board3[11][3] + board3[11][4] + board3[11][5] + board3[11][6] + board3[11][7] + board3[11][8] + board3[11][9] + board3[11][10] + board3[11][11] + board3[10][12])))
return true;
else
return false;
}
public static void flightSwitch() {
int l = 28; // from 28
do {
System.out.println("FL-" + l); //
l--;
} while(l > 0);
System.out.println();
// add a flight number where the person sees it however the user need to input Flight so it can be recalled to the boarding pass...
System.out.println("");
System.out.println("Please enter your flight > "); // Outside range still works OMEGALOL
String choosenFlight = input.next();
System.out.println("");
boardFlight.add(choosenFlight);
System.out.println("");
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment