Commit b27a86ec authored by charlie.hamer's avatar charlie.hamer

Fixes to assigning seat + comments23

parent fd747a5a
......@@ -27,11 +27,11 @@ public class airline {
public static void details() {
System.out.print("What is your name?");
System.out.print("What is your name? ");
name = input.next();
System.out.print("Where will you be flying from?");
System.out.print("Where will you be flying from? ");
ocity = input.next();
System.out.print("Where are you flying to?");
System.out.print("Where are you flying to? ");
dcity = input.next(); // getting customer details
Class();
......@@ -44,8 +44,8 @@ public class airline {
System.out.print("Choose a flight class-"
+ "\nPlease type 1 for First Class"
+ "\nPlease type 2 for Business"
+ "\nPlease type 1 for First Class "
+ "\nPlease type 2 for Business "
+ "\nPlease type 3 for Economy \n");
while(true){
switch(fclass = input.next()) {
......@@ -59,7 +59,7 @@ public class airline {
economy();
break;
default://case if user chooses an invalid option
System.out.println("Invalid option. Please choose a number from 1 to 3");//prints out an error message
System.out.println("Invalid option. Please choose a number from 1 to 3 ");//prints out an error message
break;
}}
}
......@@ -80,7 +80,7 @@ public class airline {
}
}
if(available == true) { //if seats are available
System.out.println("Would you like to choose a seat?(y/n)");
System.out.println("Would you like to choose a seat?(y/n) ");
while(true) {
String chooseseat = input.next();
switch(chooseseat) {
......@@ -117,7 +117,7 @@ public class airline {
}
if(available == true) {//if seats are available
System.out.println("Would you like to choose a seat?(y/n)");
System.out.println("Would you like to choose a seat?(y/n) ");
String chooseseat = input.next();
switch(chooseseat) {
case "n":
......@@ -154,7 +154,7 @@ public class airline {
}
}
if(available == true) {//if seats are available
System.out.println("Would you like to choose a seat?(y/n)");
System.out.println("Would you like to choose a seat?(y/n) ");
String chooseseat = input.next();
switch(chooseseat) {
case "n":
......@@ -198,37 +198,39 @@ public class airline {
private static void assign(String fclass) {
switch(fclass) {
case "First Class":
for(int i=0; i<1; i++) {
for(int i=0; i<6; i++) {
for(int j=0; j<3; j++) {
if(!seat.contentEquals(plane[i][j])) { //checks through seats, finds one that hasn't been filled yet
if(!plane[i][j].contentEquals("XX")) { //checks through seats, finds one that hasn't been filled yet
seat = plane[i][j];
plane[i][j] = "XX";
boardingpass(fclass);//loads up the boarding class
break;
}
}
}
case "Business":
for(int i=2; i<4; i++) {
for(int i=6; i<15; i++) {
for(int j=0; j<3; j++) {
if(!seat.contentEquals(plane[i][j])) { //checks through seats, finds one that hasn't been filled yet
if(!plane[i][j].contentEquals("XX")) { //checks through seats, finds one that hasn't been filled yet
seat = plane[i][j];
plane[i][j] = "XX";
boardingpass(fclass);//loads up the boarding class
break;
}
}
}
case "Economy":
for(int i=5; i<9; i++) {
for(int i=15; i<30; i++) {
for(int j=0; j<3; j++) {
if (!seat.contentEquals(plane[i][j])) { //checks through seats, finds one that hasn't been filled yet
if(!plane[i][j].contentEquals("XX")) { //checks through seats, finds one that hasn't been filled yet
seat = plane[i][j];
plane[i][j] = "XX";
boardingpass(fclass);//loads up the boarding class
break;
}
}
}
}
boardingpass(fclass); //loads up the boarding class
}
public static void chooseseat(String fclass) {
......@@ -307,7 +309,8 @@ public class airline {
System.out.println("To : " + dcity);
System.out.println("Flight : FL" + flight[select]);
System.out.println("Seat No. : " + seat);
System.out.println("Section : " + fclass);
System.out.println("Section : " + fclass); //when testing, scroll up to see whole boarding pass
System.out.println("");
display();
System.out.println("");
System.out.println("Would you like to book another?");//the choice to restart the program essentially
......
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