Commit a96f5caf authored by User's avatar User

fixes

parent 2ea5faf1
...@@ -6,7 +6,7 @@ public class reservation { ...@@ -6,7 +6,7 @@ public class reservation {
Scanner input = new Scanner(System.in); Scanner input = new Scanner(System.in);
int choice = 0; int choice = 0;
String reserve = ""; String reserve = "";
String plane[][] = {{"XX", "02", "XX"}, {"04", "05", "06"}, {"07", "08", "09"}, //initialise the array which contains the plane seats String plane[][] = {{"XX", "XX", "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"},
...@@ -59,11 +59,10 @@ public class reservation { ...@@ -59,11 +59,10 @@ public class reservation {
reserve = input.next(); reserve = input.next();
for(int s=0; s<1; s++) { for(int s=0; s<1; s++) {
for(int r=0; r<3; r++) { for(int r=0; r<3; r++) {
System.out.println(plane[s][r] + reserve); if(reserve.equals(plane[s][r])) {
if(plane[s][r] == reserve) {
System.out.println("Seat " + reserve + " has been booked for you"); System.out.println("Seat " + reserve + " has been booked for you");
plane[s][r] = "XX"; plane[s][r] = "XX";
display(plane); ticket();
return; return;
} }
} }
...@@ -85,7 +84,17 @@ public class reservation { ...@@ -85,7 +84,17 @@ public class reservation {
System.out.println("Sorry there is no available seat at the moment. The next flight is in 6 hours"); System.out.println("Sorry there is no available seat at the moment. The next flight is in 6 hours");
return; return;
case "Y": case "Y":
System.out.println("ok"); for(int s=6; s<30; s++) {
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();
return;
}
}
}
return; return;
default: default:
System.out.println("invalid input please choose Y or N"); System.out.println("invalid input please choose Y or N");
......
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