Commit a119434f authored by chris.crook's avatar chris.crook

alldone

parent 29c8d2aa
...@@ -4,6 +4,9 @@ public class ar1 { ...@@ -4,6 +4,9 @@ public class ar1 {
public static void main(String[] args) { public static void main(String[] args) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
//initiate variables
int choose = 0; int choose = 0;
int yarr = 0; int yarr = 0;
int numbercalc = 0; int numbercalc = 0;
...@@ -24,15 +27,14 @@ public class ar1 { ...@@ -24,15 +27,14 @@ public class ar1 {
String [] boardingpass = new String [7] ; String [] boardingpass = new String [7] ;
String [] [] [] flights = new String [94] [29] [2] ; String [] [] [] flights = new String [94] [29] [2] ;
//fill to remove nulls //fill storage array to remove nulls
for(int x = 0; x < 94; x++) { for(int x = 0; x < 94; x++) {
for(int y = 0; y < 29; y++) { for(int y = 0; y < 29; y++) {
flights [x] [y] [0] = "E"; flights [x] [y] [0] = "E";
} }
} }
while (ordertickets == 1){ while (ordertickets == 1){
// variable reset 1 // variable reset 1
...@@ -40,9 +42,9 @@ public class ar1 { ...@@ -40,9 +42,9 @@ public class ar1 {
continueloop = 1; continueloop = 1;
anotherseat = 1; anotherseat = 1;
//flight details //flight details input
if (yarr ==0) { if (yarr == 0) {
System.out.print(" Enter the origin airport: \n "); System.out.print(" Enter the origin airport: \n ");
origin = input.next(); origin = input.next();
System.out.print(" Enter the destination airport: \n "); System.out.print(" Enter the destination airport: \n ");
...@@ -52,32 +54,23 @@ public class ar1 { ...@@ -52,32 +54,23 @@ public class ar1 {
System.out.print(" Enter the reservation name: \n "); System.out.print(" Enter the reservation name: \n ");
name = input.next(); name = input.next();
} }
else {
//testing
}
//variable reset 2 //variable reset 2
for(int x = 0; x < 94; x++) { for(int x = 0; x < 94; x++) {
flights [x] [28] [0] = "END"; //needmore flights [x] [28] [0] = "END";
} }
//test dump
/*for(int x = 0; x < 94; x++) {
for(int y = 0; y < 29; y++) {
System.out.print(flights [x] [y] + " ");
}
System.out.println("");
}*/
//flight number calculator //flight number selector / generator
for(int y = 0; y < 29; y++) { for(int y = 0; y < 29; y++) {
if ( flights [1] [y] [0] .equals(origin)) { if ( flights [1] [y] [0] .equals(origin)) {
if ( flights [2] [y] [0] .equals(destination)) { if ( flights [2] [y] [0] .equals(destination)) { //if these match, load flight data
if ( flights [3] [y] [0] .equals(departtime)) { if ( flights [3] [y] [0] .equals(departtime)) {
mode = 1; mode = 1;
y = 28; y = 28; //force stops the for loop
} }
else { else {
mode = 2; mode = 2;
...@@ -89,21 +82,22 @@ public class ar1 { ...@@ -89,21 +82,22 @@ public class ar1 {
} }
else if ( flights [1] [y] [0] .equals("E") ) { else if ( flights [1] [y] [0] .equals("E") ) {
flightnumber = y; flightnumber = y;
mode = 1; mode = 1; //if there is an empty flight as the next available
y = 28; y = 28;
} }
else if ( flights [1] [y] [0] .equals("END")) { else if ( flights [1] [y] [0] .equals("END")) {
System.out.println("there are no more flights avalible today"); System.out.println("there are no more flights avalible today");
yarr = 1; yarr = 1; //if there are no flights, end the program
ordertickets = 0; ordertickets = 0;
} }
else { else {
mode = 2; mode = 2;
} }
//mode = 1;
//flightnumber = 1;
} }
//flight number iterator
if (mode == 2) { if (mode == 2) {
flightnumber = flightnumber + 1; flightnumber = flightnumber + 1;
if (flightnumber < 10){ if (flightnumber < 10){
...@@ -125,15 +119,8 @@ public class ar1 { ...@@ -125,15 +119,8 @@ public class ar1 {
System.out.print(""); System.out.print("");
} }
//FL = "00"; //book seats top display text
//flightnumber = 0;
/*//temporary fix for the flight number code
System.out.print(" Enter the flight number: \n ");
flightnumber = input.nextInt();
FL = flightnumber + "";*/
//book seats
if (yarr == 0) { if (yarr == 0) {
System.out.println(" ------------------------------------- \n Type in the seat number you want to have \n '[XX]' means that the seat is taken \n after selecting a seat, the boarding pass will be generated \n -------------------------------------"); System.out.println(" ------------------------------------- \n Type in the seat number you want to have \n '[XX]' means that the seat is taken \n after selecting a seat, the boarding pass will be generated \n -------------------------------------");
System.out.println(" Avalible seats: \n"); System.out.println(" Avalible seats: \n");
...@@ -143,7 +130,7 @@ public class ar1 { ...@@ -143,7 +130,7 @@ public class ar1 {
} }
String [] [] seating = new String [10] [9] ; String [] [] seating = new String [10] [9] ;
//generate //generating the seats
numbercalc = 0; numbercalc = 0;
if (yarr == 0){ if (yarr == 0){
...@@ -169,16 +156,13 @@ public class ar1 { ...@@ -169,16 +156,13 @@ public class ar1 {
seating[x] [y] = (" [" + seating[x] [y] + " "); seating[x] [y] = (" [" + seating[x] [y] + " ");
} }
//else {
// seating [x] [y] = ("");
//}
} }
} }
//load temp data (broken) //load temporary data
for(int x = 0; x < 94; x++) { for(int x = 0; x < 94; x++) {
//flights [x] [flightnumber] = "TST";
if ( flights [x] [flightnumber] [0] == "F") { if ( flights [x] [flightnumber] [0] == "F") {
choosex = (x / 10); choosex = (x / 10);
choosey = x; choosey = x;
...@@ -204,7 +188,7 @@ public class ar1 { ...@@ -204,7 +188,7 @@ public class ar1 {
} }
} }
//display //display the seats with reservation data
while (continueloop == 1) { while (continueloop == 1) {
for(int x = 0; x < 10; x++) { for(int x = 0; x < 10; x++) {
...@@ -216,9 +200,6 @@ public class ar1 { ...@@ -216,9 +200,6 @@ public class ar1 {
System.out.print(" "); System.out.print(" ");
} }
if (y >= 0) { if (y >= 0) {
//if (x < 10 && x > 0) {
// seating[x] [y] = (" [" + seating[x] [y] + " ");
//}
if (y == 3) { if (y == 3) {
System.out.print(" "); System.out.print(" ");
} }
...@@ -226,6 +207,9 @@ public class ar1 { ...@@ -226,6 +207,9 @@ public class ar1 {
System.out.print(" "); System.out.print(" ");
} }
} }
//Interrupts for displaying the area names and aisles
if (x == 0 && y == 0) { if (x == 0 && y == 0) {
System.out.print("\n ||||||||||||---=== First: Seats 1 - 18 ===---|||||||||||||||||| \n\n"); System.out.print("\n ||||||||||||---=== First: Seats 1 - 18 ===---|||||||||||||||||| \n\n");
} }
...@@ -241,70 +225,31 @@ public class ar1 { ...@@ -241,70 +225,31 @@ public class ar1 {
} }
System.out.println(""); System.out.println("");
} }
//input seat reservation
if (anotherseat == 1){ if (anotherseat == 1){
System.out.print(" enter a seat number \n "); System.out.print(" enter a seat number \n ");
choose = input.nextInt(); choose = input.nextInt();
/*for(int x = 0; x < 10; x++) {
for(int y = 0; y < 9; y++) {
if (seating [x] [y] == (" [0" + choose + "] ")){
seating [x] [y] = (" [XX] ");
}
if (seating [x] [y] == (" [" + choose + "] ")){
seating [x] [y] = (" [XX] ");
}
}
*/
//System.out.println("\n" + seating [1] [7]);
//System.out.println("HI!");
/*String [] test1 = new String[3];
test1 = choose.split("0" , 1);
test1 = choose.split("1" , 1);
test1 = choose.split("2" , 1);
test1 = choose.split("3" , 1);
test1 = choose.split("4" , 1);
test1 = choose.split("5" , 1);
test1 = choose.split("6" , 1);
test1 = choose.split("7" , 1);
test1 = choose.split("8" , 1);
test1 = choose.split("9" , 1);
System.out.println(test1 [0]);
String te = (test1 [0] + "");
String tes = (test1 [1] + "");
*///System.out.println("\n" + seating [Integer.parseInt(te)] [Integer.parseInt(te)]);
choosex = (choose / 10); choosex = (choose / 10);
choosey = choose; choosey = choose;
//System.out.println(choosex + "");
//System.out.println((choose / 10) + "");
mode = 4; mode = 4;
while (mode == 4){ while (mode == 4){
if (choosey >= 10) { if (choosey >= 10) {
choosey = choosey - 10; choosey = choosey - 10;
//System.out.println(choosey);
} }
else if (choosey < 0) { else if (choosey < 0) {
choosey = choose; choosey = choose;
} }
else { else {
mode = 5; mode = 5;
//choosey = choosey * 10;
} }
} }
//System.out.println(choosex + "");
//System.out.println(choosey + "");
if ((choosey + (choosex -1)) > 8){ if ((choosey + (choosex -1)) > 8){
choosey = choosey - 10; choosey = choosey - 10;
choosex = choosex + 1; choosex = choosex + 1;
} }
if (seating [choosex] [(choosey + (choosex - 1))] == " [XX] ") { if (seating [choosex] [(choosey + (choosex - 1))] == " [XX] " || seating [choosex] [(choosey + (choosex - 1))] == " [><] ") {
System.out.println(" seat already taken"); System.out.println(" seat already taken");
} }
else { else {
...@@ -312,6 +257,9 @@ public class ar1 { ...@@ -312,6 +257,9 @@ public class ar1 {
System.out.println(" seat booked \n \n seat location in the aircraft: [><] indicates allocated seat"); System.out.println(" seat booked \n \n seat location in the aircraft: [><] indicates allocated seat");
anotherseat = 0; anotherseat = 0;
} }
//selecting the seat class
if (choose < 19) { if (choose < 19) {
area = "First"; area = "First";
} }
...@@ -328,50 +276,34 @@ public class ar1 { ...@@ -328,50 +276,34 @@ public class ar1 {
else { else {
continueloop = 0; continueloop = 0;
} }
} }
System.out.println(""); System.out.println("");
//displaying the boarding pass
boardingpass [0] = " YSJ Airways boarding pass:"; boardingpass [0] = " YSJ Airways boarding pass:";
boardingpass [1] = " origin airport: ----- " + origin; boardingpass [1] = " origin airport: ----- " + origin;
boardingpass [2] = " destination airport:- " + destination; boardingpass [2] = " destination airport:- " + destination;
boardingpass [3] = " departure time: ----- " + departtime; boardingpass [3] = " departure time: ----- " + departtime;
boardingpass [4] = " flight number: ------ FL-" + FL; boardingpass [4] = " flight number: ------ FL-" + FL;
boardingpass [5] = " seat reservation: --- " + choose + " (" + area + ")"; boardingpass [5] = " seat reservation: --- " + choose + " (" + area + ")";
boardingpass [6] = " reservation name: --- " + name; boardingpass [6] = " reservation name: --- " + name;
for(int x = 0; x < 7; x++) { for(int x = 0; x < 7; x++) {
System.out.println(boardingpass[x]); System.out.println(boardingpass[x]);
} }
//saving to the array //saving to the temporary data array
flights [0] [flightnumber] [0] = FL; flights [0] [flightnumber] [0] = FL;
flights [1] [flightnumber] [0] = origin; flights [1] [flightnumber] [0] = origin;
flights [2] [flightnumber] [0] = destination; flights [2] [flightnumber] [0] = destination;
flights [3] [flightnumber] [0]= departtime; flights [3] [flightnumber] [0]= departtime;
flights [choose + 3] [flightnumber] [0] = "F"; flights [choose + 3] [flightnumber] [0] = "F";
flights [choose + 3] [flightnumber] [1] = name; flights [choose + 3] [flightnumber] [1] = name;
// print dump array
/*for(int x = 0; x < 94; x++) {
for(int y = 0; y < 29; y++) {
System.out.print(flights [x] [y] + " ");
}
System.out.println("");
}*/
} }
else { else {
System.out.print("have a nice day."); System.out.print("have a nice day.");
} }
} }
} }
//display();
public static void display( String[] [] seating ) {
}
} }
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