Project #1 Choose Your Own Slightly Longer Adventure
Code
/// Name: Koosha Kimelman
/// Period: 7
/// Program Name: Choose Your Own Slightly Longer Adventure
/// File Name: LongerCYOAdventure.java
/// Date Completed: 11/2/15
import java.util.Scanner;
public class LongerCYOAdventure {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String one, two, three;
System.out.println("Welcome back to ANOTHER Choose Your Own Adventure game. Except THIS one is even LONGER. And there is no way I'm going to define every single room as it's own separate variable at the beginning... even for 10 extra credit points. That takes way too long, it's unnecessary, and I don't want to do that at all. It's so much easier to just set answers based off what they just typed in, so I can use 3 variables instead of 21. IT'S SO MUCH BETTER. Anyways lets get going.");
System.out.println();
System.out.print("You walk into a building. You have no idea what it is, who it belongs to, what it's for, or why you even walked in. You see three doors, labeled as \"1\", \"2\", and \"3\". Which one do you go through? ");
one = keyboard.next();
if (one.equals("1")) {
System.out.print("Now you see two more doors, labeled \"4\" and \"5\". Which one do you go through? ");
two = keyboard.next();
if (two.equals("4")) {
System.out.print("Now there are two MORE doors, labeled with \"6\" and \"7\". Which one do you go through? ");
three = keyboard.next();
if (three.equals("6")) {
System.out.println("There is only one door in this room, with an \"11\" on it. You walk through and you leave the building. The end.");
}
else if (three.equals("7")) {
System.out.println("There is only one door in this room, with an \"12\" on it. You walk through and leave the building. The end.");
}
else {
System.out.println("You didn't give a viable answer.");
}
}
else if (two.equals("5")) {
System.out.print("Now there are two MORE doors, labeled with \"6\" and \"7\". Which one do you go through? ");
three = keyboard.next();
if (three.equals("6")) {
System.out.println("There is only one door in this room, with an \"12\" on it. You walk through and leave the building. The end.");
}
else if (three.equals("7")) {
System.out.println("There is only one door in this room, with an \"13\" on it. You walk through and leave the building. The end.");
}
else {
System.out.println("You didn't give a viable answer.");
}
}
else {
System.out.println("You didn't give a viable answer.");
}
}
else if (one.equals("2")) {
System.out.print("Now you see two more doors, labeled \"4\" and \"5\". Which one do you go through? ");
two = keyboard.next();
if (two.equals("4")) {
System.out.print("Now there are two MORE doors, labeled with \"6\" and \"7\". Which one do you go through? ");
three = keyboard.next();
if (three.equals("6")) {
System.out.println("There is only one door in this room, with an \"12\" on it. You walk through and leave the building. The end.");
}
else if (three.equals("7")) {
System.out.println("There is only one door in this room, with an \"13\" on it. You walk through and leave the building. The end.");
}
else {
System.out.println("You didn't give a viable answer.");
}
}
else if (two.equals("5")) {
System.out.print("Now there are two MORE doors, labeled with \"6\" and \"7\". Which one do you go through? ");
three = keyboard.next();
if (three.equals("6")) {
System.out.println("There is only one door in this room, with an \"13\" on it. You walk through and leave the building. The end.");
}
else if (three.equals("7")) {
System.out.println("There is only one door in this room, with an \"14\" on it. You walk through and leave the building. The end.");
}
else {
System.out.println("You didn't give a viable answer.");
}
}
else {
System.out.println("You didn't give a viable answer.");
}
}
else if (one.equals("3")) {
System.out.print("Now you see two more doors, labeled \"4\" and \"5\". Which one do you go through? ");
two = keyboard.next();
if (two.equals("4")) {
System.out.print("Now there are two MORE doors, labeled with \"6\" and \"7\". Which one do you go through? ");
three = keyboard.next();
if (three.equals("6")) {
System.out.println("There is only one door in this room, with an \"13\" on it. You walk through and leave the building. The end.");
}
else if (three.equals("7")) {
System.out.println("There is only one door in this room, with an \"14\" on it. You walk through and leave the building. The end.");
}
else {
System.out.println("You didn't give a viable answer.");
}
}
else if (two.equals("5")) {
System.out.print("Now there are two MORE doors, labeled with \"6\" and \"7\". Which one do you go through? ");
three = keyboard.next();
if (three.equals("6")) {
System.out.println("There is only one door in this room, with an \"14\" on it. You walk through and leave the building. The end.");
}
else if (three.equals("7")) {
System.out.println("There is only one door in this room, with an \"15\" on it. You walk through and leave the building. The end.");
}
else {
System.out.println("You didn't give a viable answer.");
}
}
else {
System.out.println("You didn't give a viable answer.");
}
}
else {
System.out.println("You didn't give a viable answer.");
}
}
}
Picture of the output