Commit f85e03bc authored by alexandru.radulesc's avatar alexandru.radulesc

Added an attempt of looping doesn't work

parent 942b82f1
...@@ -3,7 +3,6 @@ import java.util.Scanner; ...@@ -3,7 +3,6 @@ import java.util.Scanner;
public class Yeyey1 { public class Yeyey1 {
//--------------------------------------------------Setup Phase--------------------------------------------------\\
static 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 String[] seat = new String[100]; static String[] seat = new String[100];
static int j=0,k=0,mainSeatNumber=0,classRead; static int j=0,k=0,mainSeatNumber=0,classRead;
...@@ -24,6 +23,9 @@ public class Yeyey1 { ...@@ -24,6 +23,9 @@ public class Yeyey1 {
ShowSeats(); ShowSeats();
while(classRead!=4)
{
System.out.println("For First Class please input 1"); System.out.println("For First Class please input 1");
System.out.println("For Business Class please input 2"); System.out.println("For Business Class please input 2");
System.out.println("For Economy Class please input 3"); System.out.println("For Economy Class please input 3");
...@@ -32,6 +34,7 @@ public class Yeyey1 { ...@@ -32,6 +34,7 @@ public class Yeyey1 {
BookSeats(classRead); BookSeats(classRead);
ShowSeats(); ShowSeats();
}
} }
...@@ -42,24 +45,21 @@ public class Yeyey1 { ...@@ -42,24 +45,21 @@ public class Yeyey1 {
{ {
System.out.println("Please select a seat from 01 to 18"); System.out.println("Please select a seat from 01 to 18");
{ {
mainSeatNumber = input.nextInt(); OccupySeats();
seat[mainSeatNumber - 1] = "XX";
} }
} }
else if(mainClass == 2) else if(mainClass == 2)
{ {
System.out.println("Please select a seat from 19 to 45"); System.out.println("Please select a seat from 19 to 45");
{ {
mainSeatNumber = input.nextInt(); OccupySeats();
seat[mainSeatNumber - 1] = "XX";
} }
} }
else if(mainClass == 3) else if(mainClass == 3)
{ {
System.out.println("Please select a seat from 46 to 90"); System.out.println("Please select a seat from 46 to 90");
{ {
mainSeatNumber = input.nextInt(); OccupySeats();
seat[mainSeatNumber - 1] = "XX";
} }
} }
} }
...@@ -114,4 +114,13 @@ public class Yeyey1 { ...@@ -114,4 +114,13 @@ public class Yeyey1 {
AssignSeats(45,90); AssignSeats(45,90);
} }
public static void OccupySeats()
{
mainSeatNumber = input.nextInt();
if(seat[mainSeatNumber] !="XX")
{
seat[mainSeatNumber - 1] = "XX";
}else System.out.println("Seat is already occupied");
}
} }
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