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

Seat booking is ok

parent 7751fe2b
......@@ -4,49 +4,75 @@ import java.util.Scanner;
public class Yeyey1 {
//--------------------------------------------------Setup Phase--------------------------------------------------\\
Scanner input = new Scanner(System.in); //We're just setting up the input for now;
static int[] seat = new int[100];
static int j=0,k=0;
static Scanner input = new Scanner(System.in); //We're just setting up the input for now;
static String[] seat = new String[100];
static int j=0,k=0,mainSeatNumber=0,classRead;
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("");
System.out.println("---------------FIRST CLASS----------------");
System.out.println("");
for(int i = 0;i<90;i++)
{
seat[i] = String.valueOf(i+1);
if(i<9)
{
seat[i] = "0" + String.valueOf(i+1);
}
}
ShowSeats(0,18);
System.out.println("");
System.out.println("--------------BUSINESS CLASS--------------");
System.out.println("");
ShowSeats();
ShowSeats(18,45);
System.out.println("");
System.out.println("---------------ECONOMY CLASS--------------");
System.out.println("");
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();
BookSeats(classRead);
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++)
{
seat[i] = i+1;
if(k<9)
{
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] + "]");
j++;
}
......@@ -66,5 +92,26 @@ 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