Commit cf41296c authored by User's avatar User

comments

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