I'm trying to make a text based adventure story with options and different scenarios. When I use if(stage == *) it does not activate sysout messages, only in my switch statements or it adds it after I give an input. Edit: Since my question was a bit confusing, I need it to print everything in order, also edited all code.
private static int stage = 0;
public static void main(String[] args) throws InterruptedException {
@SuppressWarnings("resource")
Scanner in = new Scanner(System.in);
String opt = in.next().toLowerCase();
if(stage == 0) {
System.out.println("Spirit Adventure! //chose either () by typing them");
System.out.println("You regain awareness in the middle of a enchanted forest.");
System.out.println("Do you go (left) or (right)?");
switch(opt) {
case "right":
System.out.println("Swamp, you go through the thicket and move forward.");
stage = 10;
break;
case "left":
System.out.println("You find an open field with flowers all over.");
stage++;
break;
}
}
Aucun commentaire:
Enregistrer un commentaire