Skip to content

Instantly share code, notes, and snippets.

@dallarosa
Created September 28, 2014 06:46
Show Gist options
  • Save dallarosa/14617052520c571ad2ad to your computer and use it in GitHub Desktop.
Save dallarosa/14617052520c571ad2ad to your computer and use it in GitHub Desktop.
Stackoverflow answer
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(true){
System.out.println ("You enter a room and look around, in it, you see three doors, a red door labeled A, a blue door labeled B, and a green door labeled C. Which door do you choose to go through? Enter, A, B, or C");
String correctdoor = scanner.next();
if("A".equalsIgnoreCase(correctdoor)) {
break;
}
System.out.println("You have chosen wrong! You have fallen into a pit! Lucky for you though, the pit is easy to climb out of and you return to the room....\n\n\n");
}
System.out.println("You progress through the door and find 5 light switches, you must turn them on in order to progress further. Enter the correct combination (using digits 1-5) here please. HINT - the 2nd and 4th numbers add up to the first number and the last number is NOT 5");
int lightcode = 0;
while (true){
lightcode = scanner.nextInt();
if(lightcode == 31425) {
break;
}
System.out.println ("That combination is incorrect");
}
System.out.println ("The door unlocks and you go down a set of stairs");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment