Commit cf41296c authored by User's avatar User

comments

parent 6605f01f
......@@ -50,32 +50,32 @@ public class reservation{
}
if(seat == true) {//if statement to run code if seat is available
while(true) {//while loop to display options
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");
for(int s=0; s<6; s++) {
System.out.println("Would you like to choose a seat?(Y/N)");//print out options
String choose = input.next();//takes in the user input
switch(choose) {//switch case for different outcomes
case "N"://if the user types N this code is run
System.out.println("Ok, You will be assigned the next available seat");//user informed that they are given the next available seat
for(int s=0; s<6; s++) {//loop to go through the first class seats
for(int r=0; r<3; r++) {
if(plane[s][r] != "XX") {
reserve = plane[s][r];
plane[s][r] = "XX";
System.out.println("Your booked seat is " + reserve);
ticket(first,last,city,destination,section, reserve);
if(plane[s][r] != "XX") {//searches for the first seat that is NOT EQUAL to XX
reserve = plane[s][r];//sets the users' reserve seat to the array value
plane[s][r] = "XX";//sets the seat to XX so that it can't be double booked
System.out.println("Your booked seat is " + reserve);//prints out booked seat
ticket(first,last,city,destination,section, reserve);//calls the ticket function to print out the ticket details
return;
}
}
}
return;
case "Y":
System.out.println("Ok please choose a seat:"
case "Y"://if the user types Y this code is run
System.out.println("Ok please choose a seat:"//asks user to choose their seat
+ "\n Here is the plane seat layout");
display(plane);
display(plane);//calls display function to print out plane seat layout
System.out.println("\nSeat choice: ");
reserve = input.next();
if(reserve.equals("XX")) {
System.out.println("Input cannot be XX");
continue;
reserve = input.next();//grabs input from user
if(reserve.equals("XX")) {//check for if the user types in XX
System.out.println("Input cannot be XX");//print out error message
continue;//skips loop
}
for(int s=0; s<6; s++) {
for(int r=0; r<3; r++) {
......
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