I tried to add a switch statement in a method then put that method in another switch statement. It didn't work out as I expected it to... When I execute the program, the console wants me to immediately add a user input, which is not what I had in mind.
Here is what shows up in the console after I've executed the program:
qwerty
Greetings, dear Pilgrim. What is thine name?
Bob
Hello, Bob. Is thou ready to start thine quest? [Yes or No]
Please use capital letters... [Yes or No]
Application code
import java.util.Scanner;
public class rolePlay {
static Scanner player = new Scanner(System.in);
static String system;
static String choice = player.nextLine();
public void letterError() {
System.out.println("Please use capital letters...");
System.out.println(system);
switch (choice) {
case "Yes" : System.out.println("May thine travels be shadowed upon by Talos...");
break;
case "No" : System.out.println("We shall wait for thee...");
break;
default:
break;
}
}
public rolePlay() {
}
public static void main(String[] args) {
rolePlay you = new rolePlay();
System.out.println("Greetings, dear Pilgrim. What is thine name?");
String charName = player.nextLine();
System.out.println("Hello, " + charName + ". Is thou ready to start thine quest?");
system = "[Yes or No]";
System.out.println(system);
//String choice = player.nextLine();
switch (choice) {
case "Yes" : System.out.println("May thine travels be shadowed upon by Talos...");
break;
case "No" : System.out.println("We shall wait for thee...");
break;
default : you.letterError();
break;
}
player.close();
}
}