This code prompts the user to confirm a booking by typing Y or N (yes/no). If they type y or Y it calls a method setBooked() which basically just sets a boolean variable "booked" to "true". The isBooked() just returns that boolean value so I could test the before/after to see if it actually worked.
The actual code does work just not as I expected, it will immediately work properly if you type "y" but if you type anything else it will prompt you again, and again work if you type "y" but this time if you type anything else it just stops and moves on to the next "customer" (method is called about 8 times)
So basically is there a reason that it is prompting the user twice instead of just evaluating what they type the first time for "y" OR "Y"?
System.out.println(customer.isBooked());
System.out.println( "Confirm booking for " + customer.getName() + "(Y/N)");
Scanner scan = new Scanner(System.in);
if (scan.nextLine().equals("y") || scan.nextLine().equals("Y"))
customer.setBooked();
System.out.println("Booked");
System.out.println(customer.isBooked());