Commit 1a2e034b authored by User's avatar User

options

parent c44069e2
...@@ -5,7 +5,7 @@ public class reservation { ...@@ -5,7 +5,7 @@ public class reservation {
public static void main(String[] args) {//main subprogram public static void main(String[] args) {//main subprogram
Scanner input = new Scanner(System.in); Scanner input = new Scanner(System.in);
int choice = 0; int choice = 0;
String plane[][] = {{"01", "02", "03"}, {"04", "05", "06"}, {"07", "08", "09"}, //initialise the array which contains the plane seats String plane[][] = {{"XX", "02", "XX"}, {"04", "05", "06"}, {"07", "08", "09"}, //initialise the array which contains the plane seats
{"10", "11", "12"}, {"13", "14", "15"}, {"16", "17", "18"}, {"10", "11", "12"}, {"13", "14", "15"}, {"16", "17", "18"},
{"19", "20", "21"}, {"22", "23", "24"}, {"25", "26", "27"}, {"19", "20", "21"}, {"22", "23", "24"}, {"25", "26", "27"},
{"28", "29", "30"}, {"31", "32", "33"}, {"34", "35", "36"}, {"28", "29", "30"}, {"31", "32", "33"}, {"34", "35", "36"},
...@@ -23,7 +23,49 @@ public class reservation { ...@@ -23,7 +23,49 @@ public class reservation {
switch(choice = input.nextInt()) {//switch case to run different outcomes switch(choice = input.nextInt()) {//switch case to run different outcomes
case 1://case if user chooses first class/1 case 1://case if user chooses first class/1
System.out.println("You have Chosen First Class");//prints out the class that the user has chosen System.out.println("You have Chosen First Class");//prints out the class that the user has chosen
boolean seat = false;
for(int p=0; p<1; p++) {
for(int q=0; q<3; q++) {
if(plane[p][q] != "XX") {
seat = true;
}
}
}
if(seat == true) {
while(true) {
System.out.println("Would you like to choose a seat?(Y/N)");
String choose = input.next();
switch(choose) {
case "N":
System.out.println("Ok, You will be assigned the next available seat");
return;
case "Y":
System.out.println("Ok please choose a seat:");
return;
default:
System.out.println("invalid input please choose Y or N");
break; break;
}
}
}
else{
while(true){
System.out.println("There are no more seats, is it ok to be moved to another class?(Y/N)");
String choose = input.next();
switch(choose) {
case "N":
System.out.println("Sorry there is no available seat at the moment. The next flight is in 6 hours");
return;
case "Y":
System.out.println("ok");
return;
default:
System.out.println("invalid input please choose Y or N");
break;
}
}
}
//return;
case 2://case if user chooses business class/2 case 2://case if user chooses business class/2
System.out.println("You have Chosen Business Class");//prints out the class that the user has chosen System.out.println("You have Chosen Business Class");//prints out the class that the user has chosen
break; break;
......
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