I m new, please have patience with me :)
I m not figure out why this method it s not working properly. It is creating me the account but, when the account was successfully created, it s not running well on the same method mainMenu(). I used a recursive call of the same method.... In the debug seems that it s not something well with my scanner from the second call of the method.
I m a Student
public void mainMenu() {
System.out.println("Select your option: ");
System.out.println("1. Open a new account");
System.out.println("2. Display all accounts");
System.out.println("If you want to logout press 9");
Scanner sc = new Scanner(System.in);
int option = 0;
do {
try {
option = sc.nextInt();
System.out.println();
switch (option) {
case 1:
accountUtil.openNewAccount(userConsoleUtil.getUser().getUserName());
mainMenu();
break;
case 9:
userConsoleUtil.logout();
displayLoginMenu();
break;
default:
System.out.println("Invalid option! Try again");
}
} catch (InputMismatchException e) {
System.out.println("Invalid option! Try again");
}
sc.nextLine();
} while (option != 9);
sc.close();
}
if the object account was created, it should return to beginning of the method, allowing to create a new account or exit with logout