Commit 8e106cb4 authored by LoomyGames's avatar LoomyGames

Everuthing is functional, Alelujah

parent 94d2adae
......@@ -3,39 +3,75 @@ import java.util.Scanner;
public class Yeyey1 {
static Scanner input = new Scanner(System.in); //We're just setting up the input for now;
static String[] seat = new String[100];//Seat array
static int j=0,k=0,mainSeatNumber=0,classRead;//Seat number and seat class, both inputs from the user
static String[][] seat = new String[100][29];//Seat array
static int j=0,k=0,p=0,i=0,mainSeatNumber=0,classRead;//Seat number and seat class, both inputs from the user
static String personName;// name, destination and city, will be printed on the boarding pass
static String destination;
static String currentCity;
static String[] planeName = new String[28];
static int bookAgain = 1;// variable to check if the user wants to book another seat
static int isPlaneFull = 0;//variable to check whether the selected plane is full
static int time = 0;//variable for the time (0/6/12/18/0 again)
static String planeClass;
public static void main(String[] args) {
for(int i = 0;i<90;i++)
for(i = 0;i<90;i++)
{
seat[i] = String.valueOf(i+1);
for(p=0;p<28;p++)
{
seat[i][p] = String.valueOf(i+1);
if(i<9)
{
seat[i] = "0" + String.valueOf(i+1);
seat[i][p] = "0" + String.valueOf(i+1);
}
}
}//here we set up the numbers for the seats
for(int i = 0; i<28; i++)
{
if(i<9)
p=0;
/*for(i = 0; i<90; i++)
{
planeName[i] = "FL0" + (i + 1);
}
else
planeName[i] = "FL" + (i + 1);
}//here we set up the flight names
seat[i][0] = "XX";
seat[i][1] = "XX";
}*/ //uncomment this for to fill 2 planes and see the system assigning seats to the 3rd plane- FL3
GiveInfo();//here we ask the user for his info1
GiveInfo();//here we ask the user for his info
while(true)
{
planeName[p] = "FL" + (p+1);//assign the plane's name in relation to p-the filled plane variable
if(p>27)//if there are 28 filled planes, the program exits
{
System.out.println("There are no available flights for this week");
break;
}
else//otherwise it checks whether all the seats of a plane are filled
{
for(i=0;i<90;i++)
{
if(seat[i][p] != "XX")//if it didn't find any XX seats the plane isn't full
{
isPlaneFull=0;
}
else isPlaneFull = 1;//otherwise it is
}
if(isPlaneFull == 1)//if it is full, p-the filled plane variable gains 1 and the name changes from for example FL1 to FL2 and so on
{
p++;
isPlaneFull = 0;
time+=6;
planeName[p] = "FL" + (p+1);
}
}
if(time == 24)//if the time reaches 24, reset it to 0, which is midnight
{
time = 0;
}
if(bookAgain == 1)//if the user wishes to book
{
System.out.println("");
......@@ -49,22 +85,22 @@ public class Yeyey1 {
System.out.println("Would you like to book another seat? 0 = no / 1 = yes");
bookAgain = input.nextInt();//ask the user if he wishes to book again
}
else if(bookAgain == 0)//if not, we show his boarding pass and exit
else if(bookAgain == 0)//if not, we exit
{
ShowBoardingPass();
System.out.println("Have a good day!");
break;
}
}
}
public static void BookSeats(int mainClass) //Method for asking the user for his seat number
{
public static void BookSeats(int mainClass) //Method for asking the user for his seat number and give planeClass the designated class
{ //to be printed on the Boarding Pass
if(mainClass == 1)
{
System.out.println("Please select a seat from 1 to 18");
{
planeClass = "First";
OccupySeats();
}
}
......@@ -72,6 +108,7 @@ public class Yeyey1 {
{
System.out.println("Please select a seat from 19 to 45");
{
planeClass = "Business";
OccupySeats();
}
}
......@@ -79,6 +116,7 @@ public class Yeyey1 {
{
System.out.println("Please select a seat from 46 to 90");
{
planeClass = "Economy";
OccupySeats();
}
}
......@@ -86,13 +124,13 @@ public class Yeyey1 {
public static void AssignSeats(int start, int finish)//method for assigning seats and adding the changes to
{ //them (if they're occupied)
for(int i = start;i<finish;i++)//start and finish are assigned in the ShowSeats method
for(i = start;i<finish;i++)//start and finish are assigned in the ShowSeats method
{
if(k<9)
{
if(j<3)
{
System.out.print("[" + seat[i] + "]");
System.out.print("[" + seat[i][p] + "]");
j++;
}
if(j==3)
......@@ -136,10 +174,11 @@ public class Yeyey1 {
public static void OccupySeats()//method for displaying the occupied seats
{
mainSeatNumber = input.nextInt();
if(seat[mainSeatNumber - 1] !="XX")//we verify if the seat is already taken
if(seat[mainSeatNumber - 1][p] !="XX")//we verify if the seat is already taken
{
seat[mainSeatNumber - 1] = "XX";//if not, occupy it and show the seats
seat[mainSeatNumber - 1][p] = "XX";//if not, occupy it and show the seats
ShowSeats();
ShowBoardingPass();
}
else
{
......@@ -156,7 +195,8 @@ public class Yeyey1 {
currentCity = input.next();
System.out.print("Please enter your destination: ");
destination = input.next();
ShowSeats();
System.out.print("Please enter your desired time: ");
time = input.nextInt();
}
public static void ShowBoardingPass()//method for displaying the boarding pass
......@@ -167,7 +207,9 @@ public class Yeyey1 {
System.out.println(" Current City:-- " + currentCity);
System.out.println(" Destination:--- " + destination );
System.out.println(" Seat:---------- " + mainSeatNumber);
System.out.println(" Flight:-------- " + planeName[0]);
System.out.println(" Flight:-------- " + planeName[p]);
System.out.println(" Time:---------- " + time);
System.out.println(" Class:--------- " + planeClass);
System.out.println(" -------------------------------------------");
System.out.println("");
}
......
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