Difficulty in booking movie tickets
Once again, hey to all JF Members :D
Right now, I'm doing an assignment on Movie Booking. And I'm having problems booking movie tickets, then update the member's purchased ticket count; and marking an X on the seat to specify that it's booked. FYI, I'm using 2D Array for the seats.
Code:
else if (menuChoice == 4) {
// Login > Choose Hall > Movie > If tickets bought = > 4, System.out.println("cannot book more than 4 tic);
//Book ticket
System.out.println("Entering Booking System. ");
System.out.println("Please enter member name: ");
String name = userInputS.nextLine();
System.out.println("Please enter member password: ");
String password = userInputS.nextLine();
for (Member member : memberList) {
/*if(member.name !=name && member.password != password) {
System.out.println("Either one or both of your entered credentials is incorrect, please try again.");
break;
}*/ // can't seem to work :l
if (member.name.equalsIgnoreCase(name) && member.password.equalsIgnoreCase(password)) {
System.out.println("Please choose the hall you wish to watch in: ");
System.out.println("1. Hall 1");
System.out.println("2. Hall 2");
System.out.println("3. Hall 3");
System.out.print("Enter your choice : ");
int hallChoice = userInputI.nextInt();
while (hallChoice != 1 && hallChoice !=2 && hallChoice != 3){
System.out.println("Please enter again! Invalid option!");
System.out.println("\t1. Hall 1");
System.out.println("\t2. Hall 2");
System.out.println("\t3. Hall 3");
System.out.print("\nEnter your choice : ");
hallChoice = userInputI.nextInt();
}
String Letters[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
if (hallChoice == 1) {
System.out.println("Please choose your preferred movie: ");
userInputS.nextLine();
System.out.println("Please enter the number of tickets you wish to buy");
@SuppressWarnings("unused")
int noOfTickets = userInputI.nextInt();
String[][]Hall1 = new String[5][6];
System.out.println("X = Seat taken");
System.out.println("\n\t<<------------ SCREEN ------------ >>");
for(int i = 0; i<5; i++){
System.out.println();
for(int j = 0; j<6; j++){
System.out.print(Hall1[i][j] = Letters[i] + (j+1+"[ ]") + " ");
}
}
System.out.println("");
System.out.println("");
System.out.println("Please choose your preferred seat(s): ");
userInputS.nextLine();
} else if (hallChoice == 2) {
System.out.println("Please choose your preferred movie: ");
userInputS.nextLine();
System.out.println("Please enter the number of tickets you wish to buy");
@SuppressWarnings("unused")
int noOfTickets = userInputI.nextInt();
String[][]Hall2 = new String[10][10];
System.out.println("X = Seat taken");
System.out.println("\n\t<<------------ SCREEN ------------ >>");
for(int i = 0; i<10; i++){
System.out.println();
for(int j = 0; j<10; j++){
System.out.print(Hall2[i][j] = Letters[i] + (j+1+"[ ]") + " ");
}
}
System.out.println("");
System.out.println("");
System.out.println("Please choose your preferred seat(s): ");
userInputS.nextLine();
} else if (hallChoice == 3) {
System.out.println("Please choose your preferred movie: ");
userInputS.nextLine();
System.out.println("Please enter the number of tickets you wish to buy");
@SuppressWarnings("unused")
int noOfTickets = userInputI.nextInt();
String[][]Hall3 = new String[12][10];
System.out.println("X = Seat taken");
System.out.println("\n\t<<------------ SCREEN ------------ >>");
for(int i = 0; i<12; i++){
System.out.println();
for(int j = 0; j<10; j++){
System.out.print(Hall3[i][j] = Letters[i] + (j+1+"[ ]") + "\t");
}
}
System.out.println("");
System.out.println("");
System.out.println("Please choose your preferred seat(s): ");
userInputS.nextLine();
}
}
}
}
+rep if you helped, even if it doesn't make sense :p