Commit 7be967a6 authored by quinn.haigh's avatar quinn.haigh

first commit

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flightrepository</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
package flightrepository;
//import scanner to be able use scanner
import java.util.Scanner;
public class repository {
// List of all Static variables
public static Scanner input = new Scanner(System.in);
public static int numberAssigner = 1;
public static int userInput;
public static String selectSeat;
public static boolean seatTaken = false;
public static String name;
public static String originDestination;
public static String destination;
public static int flightNum = 01;
//setting boundaries and names of the arrays
public static String[][] first_class = new String [9][2];
public static String[][] business_class = new String[9][3];
public static String[][] economy_class = new String[9][5];
//setting main method
public static void main(String[] args)
{
//populating seating classes
populateSeatNum(first_class);
populateSeatNum(business_class);
populateSeatNum(economy_class);
menuChoice();
}
//function for generating boarding pass
public static void boardingPass()
{
System.out.println("|[ BOARDING PASS ]|");
System.out.println("name :" + name );
System.out.println("From :" + originDestination);
System.out.println("To :" + destination);
System.out.println("Flight :" + flightNum);
System.out.println("Seat No :" + selectSeat);
System.out.println("Section :FL" + flightNum);
flightNum++;
}
//function for assigning seat
public static void chooseSeat(String[][] seats) {
System.out.println("Enter seat you wish to book > ");
selectSeat = input.next();
for (int i = 0; i < seats[0].length; i++)
{
if(seatTaken == true)
{
break;
}
for (int j = 0; j < seats.length; j++)
{
// Assign seat if free
if (selectSeat.equals(seats[j][i]))
{
seats[j][i] = "XX";
seatTaken = true;
if(seatTaken == true)
{
System.out.println("Seat " + selectSeat + " booked");
boardingPass();
break;
}
classAssigner(seats);
}
}
}
}
//Assigning the seats in each class type array
public static void assignSeat(String[][]seatAssign) {
for(int column =0; column < seatAssign[0].length; column++)
{
for(int row=0; row < seatAssign.length; row++)
{
seatAssign[row][column] = Integer.toString(numberAssigner);
numberAssigner++;
}
}
}
//setting up the main menu
public static void menuChoice() {
//collecting details of customer for baording pass
System.out.println("Please enter name > " );
name = input.next();
System.out.println("City of Origin > ");
originDestination = input.next();
System.out.println("Destination travelling to > ");
destination = input.next();
//menu for classes
System.out.println("please choose which class you would like,\n"
+ "1 for first class,\n"
+ "2 for business class, \n"
+ "3 for economy class, \n ");
int customerChoice = input.nextInt();
switch(customerChoice) {
case 1:
classAssigner(first_class);
break;
case 2:
classAssigner(business_class);
break;
case 3:
classAssigner(economy_class);
}
}
// assign and create seat charts for each class
public static void classAssigner(String[][]assignClass) {
int counter = 1;
for(int column =0; column < assignClass[0].length; column++)
{
counter = 1;
for(int row=0; row < assignClass.length; row++)
{
if(counter > 3) {
System.out.print(" " + "[" + assignClass[row][column] + "]" + "" );
counter =1;
}
else
{
System.out.print("[" + assignClass[row][column] + "]" + "" );
}
counter++;
}
System.out.println();
}
chooseSeat(assignClass);
}
//Initialize 2-D array which is called seatAssign
public static void populateSeatNum(String[][]seatAssign)
{
for(int column =0; column < seatAssign[0].length; column++)
{
for(int row=0; row < seatAssign.length; row++)
{
seatAssign[row][column] = Integer.toString(numberAssigner);
numberAssigner++;
}
}
}
}
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