I am creating a text-based game and, so far, I have gotten the if and the else statements to work. However, the else if does not work. I've gone through several sites and several pages and even talked with a fellow coder. I've done what I can, such as replacing == with "?".equals(Call#)) then changing to Call#.equals("?"). I had the else if as a nested if but that also failed.
public static void FirstRoom(){
System.out.println("You are in a room filled with\ndarkness and no memory of your\npast. There are several objects\nscattered on the ground and a\nlantern in your hand. You find\na lighter in your pocket.");
System.out.println("\n ----- \n");
Scanner console = new Scanner(System.in);
String Call = console.next();
if (Call.equals("Inspect")) {
System.out.println("\nYou can only see darkness");
System.out.println("\n ----- \n");
} else if(Call.equals("Light Lantern")){
System.out.println("\nYou pull the lighter from your pocket and,\nturning the knob, raise the\nlantern's wick and light it.");
System.out.println("\n ----- \n");
}else{
System.out.println("\nWhat do you mean?");
System.out.println("\n ----- \n");
FirstRoom();
}
String Call2 = console.next();
if(Call.equals("Inspect")) {
System.out.println("You see a large sword to your\nright and a bag to the left.\nThere is a door in front\n of you and a door behind.");
System.out.println("\n ----- \n");
}
}
When I type in Light Lantern, I expect it to say You pull the lighter from your pocket and, turning the knob, raise the lantern's wick and light it. Instead, it skips to the second statement (supposed to also wait for you to input for the second) and says You see a large sword to your right and a bag to your left. There is a door in front of you and a door behind.
Inspect
You can only see darkness
Light Lantern You see a large sword to your right and a bag to your left. There is a door in front of you and a door behind.