Assignment #45 and Choose Your Own Adventure
Code
/// Name: Graham Pollock
/// Period: 5
/// Program Name: Choose Your Own Adventure
/// File Name: ChooseYourOwnAdventure.java
/// Date Finished: 11/05/2015/
import java.util.*;
public class Adventure
{
public static void main ( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String a1, a2, a3;
System.out.println("WELCOME TO GRAHAM'S TINY ADVENTURE");
//question one
System.out.println("You are in a creepy house! Would you like to go upstairs or into the kitchen?"); //stairs or kitchen
a1 = keyboard.next();
if (a1.equals("upstairs") ) //r1
{
//question two
System.out.println("Upstairs you see a hallway. At the end of the hallway is the master \"bedroom\". There is also a \"bathroom\" off the hallway. Where would you like to go?"); //bed or bath?
a2 = keyboard.next();
if (a2.equals("bedroom") )//r2
{
//question three
System.out.println("You are in a plush bedroom, with expensive-looking hardwood furniture. The bed is unmade. In the back of the room, the closet door is ajar. Would you like to open the door? (\"yes\" or \"no\") "); //yes or no
a3 = keyboard.next();
if (a3.equals("yes") )
{
System.out.println("There is a monster in the closet, you get eaten");
//ending 1
}
else if (a3.equals("no") )
{
System.out.println("The all doors suddenly close and lock, you are trapped.");
//ending 2
}
else
{
System.out.println("ERROR!! SPELL CORRECTLY, NO CAPS");
}
}
else if (a2.equals("bathroom") ) //yes or no
{
System.out.println("In the bathroom there is a shower curtain, do you pull it back to reveal what's behind it?");
a3 = keyboard.next();
if (a3.equals("yes") )
{
System.out.println("There is a serial killer waiting for you the other side, OOPS!");
//ending 3
}
else if (a3.equals("no") )
{
System.out.println("You back out slowly and get lost in the house.");
//ending 4
}
else
{
System.out.println("ERROR!! SPELL CORRECTLY, NO CAPS");
}
}
else
{
System.out.println("ERROR!! SPELL CORRECTLY, NO CAPS");
}
}
else if (a1.equals("kitchen") )//r1
{
//question two
System.out.println("There is a long countertop with dirty dishes everywhere. Off to one side there is, as you'd expect, a refrigerator. You may open the refrigerator or look in a cabinet"); //fridge or cabinet
a2 = keyboard.next();
if (a2.equals("refrigerator") )
{
//question three
System.out.println("Inside the refrigerator you see food and stuff. It looks pretty nasty. Would you like to eat some of the food? (\"yes\" or \"no\") "); //yes or no
a3 = keyboard.next();
if (a3.equals("yes") )
{
System.out.println("You get sick and die... eventually");
//ending 5
}
else if (a3.equals("no") )
{
System.out.println("You die of starvation... eventually.");
//ending 6
}
else
{
System.out.println("ERROR!! SPELL CORRECTLY, NO CAPS");
}
}
else if (a2.equals("cabinet") ) //yes or no
{
System.out.println("You find a tunnel on the other side. Do you go through it? (\"yes\" or \"no\")");
a3 = keyboard.next();
if (a3.equals("yes") )
{
System.out.println("You found the tunnel to Narnia, you are the new ruler");
//ending 7
}
else if (a3.equals("no") )
{
System.out.println("The tunnel eventualy closes, you are lost in the house.");
//ending 8
}
else
{
System.out.println("ERROR!! SPELL CORRECTLY, NO CAPS");
}
}
else
{
System.out.println("ERROR!! SPELL CORRECTLY, NO CAPS");
}
}
else
{
System.out.println("ERROR!! SPELL CORRECTLY, NO CAPS");
}
}
}
Picture of the output