I have methods with which I get data from a database. Depending on the variable that the user entered through the console, I must execute the desired method
while (flag) {
try {
sw = new ScannerWrapper();
menuHeader();
int choice = sw.readInt();
switch (choice) {
case 1:
System.out.println("Input first name: ");
String name = sw.readLine().toUpperCase();
printResults(DataParser.getFilmByName(name));
break;
case 0:
System.out.println("Bye-bye. Come again");
flag = false;
break;
default:
System.out.println("Please enter correct number");
}
} catch (Exception e) {
System.out.println("Enter correct data"); …Run Code Online (Sandbox Code Playgroud)