Commit 586ff3a3 authored by User's avatar User

class fix

output correction
parent 10fba06b
...@@ -98,17 +98,31 @@ public class reservation { ...@@ -98,17 +98,31 @@ 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":
for(int s=6; s<30; s++) { for(int s=6; s<15; s++) {
for(int r=0; r<3; r++) { for(int r=0; r<3; r++) {
if(plane[s][r] != "XX") { if(plane[s][r] != "XX") {
reserve = plane[s][r]; reserve = plane[s][r];
plane[s][r] = "XX"; plane[s][r] = "XX";
section = "Business";
System.out.println("Your booked seat is " + reserve); System.out.println("Your booked seat is " + reserve);
ticket(first,last,city,destination,section, reserve); ticket(first,last,city,destination,section, reserve);
return; return;
} }
} }
} }
for(int s=15; s<30; s++) {
for(int r=0; r<3; r++) {
if(plane[s][r] != "XX") {
reserve = plane[s][r];
plane[s][r] = "XX";
section = "Economy";
System.out.println("Your booked seat is " + reserve);
ticket(first,last,city,destination,section, reserve);
return;
}
}
}
System.out.println("Sorry there is no available seat in any class at the moment. The next flight is in 6 hours");
return; return;
default: default:
System.out.println("invalid input please choose Y or N"); System.out.println("invalid input please choose Y or N");
...@@ -204,13 +218,14 @@ public class reservation { ...@@ -204,13 +218,14 @@ public class reservation {
} }
public static void ticket(String first, String last, String city, String destination, String section, String reserve) { public static void ticket(String first, String last, String city, String destination, String section, String reserve) {
System.out.println("Here are your ticket details:" System.out.println("Here are your ticket details:"
+ "|{BOARDING PASS}|" + "\n|{BOARDING PASS}|"
+ "\n Name: " + first + " " + last + "\n Name: " + first + " " + last
+ "\n From: " + city + "\n From: " + city
+ "\n To: " + destination + "\n To: " + destination
+ "\n Flight: " + "\n Flight: "
+ "\n Seat No.: " + reserve + "\n Seat No.: " + reserve
+ "\n Section: " + section); + "\n Section: " + section
+ "\n--------------------------");
System.out.println("Thanks for using our booking service"); System.out.println("Thanks for using our booking service");
display(plane); display(plane);
} }
......
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