For some reason the error for try and catch pops up when i first run the program without inputting anything for the try and catch to detect. checked the error with e.LocalizedMessage and got this error?
public static void orderFlow(restaurant restaurant){
System.out.println("\nWelcome to " + restaurant.getName());
restaurant.printMenu();
order order = new order();
while (true){
System.out.print("Choose item number, 0 to back, or 'done': ");
String choice = scanner.nextLine();
if (choice.equals("0")){
return;
}
else if (choice.equalsIgnoreCase("done")){
break;
}
int test;
try {
test = Integer.parseInt(choice) - 1;
}
catch (Exception e) {
System.out.println("Invalid!" + e.getLocalizedMessage());
continue;
}
if (test < 0 || test >= restaurant.getMenu().size()) {
System.out.println("Invalid!");
continue;
}