Commit f433acdf authored by jonathan.craske's avatar jonathan.craske

Update flightbooking.java

parent a8cc2090
package flightbooking;
// importing scanner
import java.util.Scanner;
public class flightbooking {
// declaring the name of the scanner
public static Scanner input = new Scanner(System.in);
// declaring public variables
public static int userInput;
public static String selectSeat;
public static boolean seatTaken = false;
public static int flightNum = 01;
public static boolean seatUsed = false;
public static String pickSeat;
public static String name;
public static String originDestination;
public static String start;
public static String destination;
public static int flightNum = 01;
public static String[][] first_class = new String [9][2];
public static String[][] business_class = new String[9][3];
......@@ -27,12 +31,13 @@ public static int numberAssigner = 1;
//function for generating boarding pass
public static void boardingPass()
{
// printing out a boarding pass to the user
System.out.println("|[ BOARDING PASS ]|");
System.out.println("Name :" + name );
System.out.println("From :" + originDestination);
System.out.println("From :" + start);
System.out.println("Destination :" + destination);
System.out.println("Flight :" + flightNum);
System.out.println("Seat No :" + selectSeat);
System.out.println("Seat No :" + pickSeat);
System.out.println("Section :FL" + flightNum);
flightNum++;
}
......@@ -40,25 +45,26 @@ public static int numberAssigner = 1;
//function to assign a seat
public static void chooseSeat(String[][] seats)
{
// getting user to choose their seat
System.out.println("Enter seat you wish to book > ");
selectSeat = input.next();
pickSeat = input.next();
for (int i = 0; i < seats[0].length; i++)
{
if(seatTaken == true)
if(seatUsed == true)
{
break;
}
for (int j = 0; j < seats.length; j++)
{
// assigns seat if it is free
if (selectSeat.equals(seats[j][i]))
if (pickSeat.equals(seats[j][i]))
{
seats[j][i] = "XX";
seatTaken = true;
if(seatTaken == true)
seatUsed = true;
if(seatUsed == true)
{
System.out.println("Seat " + selectSeat + " booked");
System.out.println("Seat " + pickSeat + " booked");
boardingPass();
break;
}
......@@ -71,14 +77,15 @@ public static int numberAssigner = 1;
// function for menu choices
public static void menuChoice()
{
//menu for classes
// getting details about the users journey
System.out.println("Please enter name > " );
name = input.next();
System.out.println("City of Origin > ");
originDestination = input.next();
System.out.println("Destination travelling to > ");
System.out.println("Start location > ");
start = input.next();
System.out.println("Desired destination > ");
destination = input.next();
// getting the user to decide which section they want to sit in
System.out.println("please choose which class you would like,\n"
+ "1 for first class,\n"
+ "2 for business class, \n"
......@@ -98,7 +105,7 @@ public static int numberAssigner = 1;
}
}
// assign and create seat charts for each class
// assign and create seating plan for each class
public static void classAssigner(String[][]assignClass)
{
int counter = 1;
......@@ -123,7 +130,7 @@ public static int numberAssigner = 1;
chooseSeat(assignClass);
}
//Initialize 2-D array which is called seatClass
// initialize 2d array
public static void populateSeatNum(String[][]seatAssign)
{
for(int column =0; column < seatAssign[0].length; column++)
......
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