Commit 942b82f1 authored by alexandru.radulesc's avatar alexandru.radulesc

Seat booking is ok

parent 7751fe2b
...@@ -4,49 +4,75 @@ import java.util.Scanner; ...@@ -4,49 +4,75 @@ import java.util.Scanner;
public class Yeyey1 { public class Yeyey1 {
//--------------------------------------------------Setup Phase--------------------------------------------------\\ //--------------------------------------------------Setup Phase--------------------------------------------------\\
Scanner input = new Scanner(System.in); //We're just setting up the input for now; static Scanner input = new Scanner(System.in); //We're just setting up the input for now;
static int[] seat = new int[100]; static String[] seat = new String[100];
static int j=0,k=0; static int j=0,k=0,mainSeatNumber=0,classRead;
public static void main(String[] args) { public static void main(String[] args) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
System.out.println(""); for(int i = 0;i<90;i++)
System.out.println("---------------FIRST CLASS----------------"); {
System.out.println(""); seat[i] = String.valueOf(i+1);
if(i<9)
{
seat[i] = "0" + String.valueOf(i+1);
}
ShowSeats(0,18); }
System.out.println(""); ShowSeats();
System.out.println("--------------BUSINESS CLASS--------------");
System.out.println("");
ShowSeats(18,45); System.out.println("For First Class please input 1");
System.out.println("For Business Class please input 2");
System.out.println("For Economy Class please input 3");
classRead = input.nextInt();
System.out.println(""); BookSeats(classRead);
System.out.println("---------------ECONOMY CLASS--------------");
System.out.println("");
ShowSeats(45,90); ShowSeats();
} }
public static void BookSeats(int classNum) //Method for adding the seats and displaying them yey public static void BookSeats(int mainClass) //Method for adding the seats and displaying them yey
{ {
if(mainClass == 1)
{
System.out.println("Please select a seat from 01 to 18");
{
mainSeatNumber = input.nextInt();
seat[mainSeatNumber - 1] = "XX";
}
}
else if(mainClass == 2)
{
System.out.println("Please select a seat from 19 to 45");
{
mainSeatNumber = input.nextInt();
seat[mainSeatNumber - 1] = "XX";
}
}
else if(mainClass == 3)
{
System.out.println("Please select a seat from 46 to 90");
{
mainSeatNumber = input.nextInt();
seat[mainSeatNumber - 1] = "XX";
}
}
} }
public static void ShowSeats(int start, int finish) public static void AssignSeats(int start, int finish)
{ {
for(int i = start;i<finish;i++) for(int i = start;i<finish;i++)
{ {
seat[i] = i+1;
if(k<9) if(k<9)
{ {
if(j<3) if(j<3)
{ {
if(i<9) System.out.print("[0" + seat[i] + "]"); if(i<9) System.out.print("[" + seat[i] + "]");
else System.out.print("[" + seat[i] + "]"); else System.out.print("[" + seat[i] + "]");
j++; j++;
} }
...@@ -67,4 +93,25 @@ public class Yeyey1 { ...@@ -67,4 +93,25 @@ public class Yeyey1 {
} }
} }
public static void ShowSeats()
{
System.out.println("");
System.out.println("---------------FIRST CLASS----------------");
System.out.println("");
AssignSeats(0,18);
System.out.println("");
System.out.println("--------------BUSINESS CLASS--------------");
System.out.println("");
AssignSeats(18,45);
System.out.println("");
System.out.println("---------------ECONOMY CLASS--------------");
System.out.println("");
AssignSeats(45,90);
}
} }
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