All my methods work fine when being called singely.
I have two menus one Main
and for the Customer
.
public void getMainMenuChoice() {
Scanner kb =new Scanner(System.in);
boolean check = true;
while(check) {
Menu.mainMenu();
int choice = kb.nextInt();
switch(choice) {
case 0:
System.out.println("Goodbye");
check = false;
break;
case 1:
getCustomerMenuChoice();
case 2:
Menu.mainMenu();
}
}
}
//Employee Choice from the Menu
public void getCustomerMenuChoice() {
Scanner kb =new Scanner(System.in);
Menu.customerMenu();
int choice = kb.nextInt();
switch(choice) {
case 0:
Menu.mainMenu();
case 1:
customerWithdraw();
case 2:
System.out.println("In progress");
case 3:
createCustomerAccount();
case 4:
System.out.println("Enter Customer Passport");
String passportNumber = kb.nextLine();
findCustomer(passportNumber);
System.out.println("Waiting");
}
}
In main when I call the getMainMenuChoice() I can select the customer menu
When I am in this menu and for example call 4 findCustomer() It just reloads the the mainMenu and prints waiting
at the top while prompting me to enter the passport number.
This is a run through of what happens
Enter:
Customer Menu
Employee Menu
Quit Application.
Selection -> 1
Enter:
Customer Withdraw
Customer Deposit
Create Account
Delete Customer
Find Customer
Display All Customers
Back
Selection -> 4
Enter Customer Passport
//It just ignores the method and prints the menu below as well Enter Customer Passport
Enter:
Customer Menu
Employee Menu
Quit Application.
Selection ->
//Finding a customer
public Customer findCustomer(String passportNumber) {
for(Customer currentCustomer : listCustomer)
if(currentCustomer.getPassportNumber().equals(passportNumber)) {
System.out.println("Customer Found: " + currentCustomer);
return currentCustomer;
}
return null;
}
I am not sure why this happens I have been trying to debug for a few hours now.
Is it something to do with the while loop in the getMainMenuChoice()?