Assignment 45: Choose Your Own Adventure
Code
/// Name: Ryan McAteer
/// Period: 5
/// Program Name: Choose Your Own Adventure
/// File Name: Assignment45.java
/// Date Finished: 10/26/15
import java.util.Scanner;
class Assignment45
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
String room1, room2, room3;
room1 = room2 = room3 = "room";
System.out.println( "Welcome to Ryan's Adventure! (I'm not creative)" );
System.out.println();
System.out.println( "You are in a creepy house! Would you like to go [upstairs] or to the [main hall]? " );
System.out.print( "> " );
room1 = keyboard.nextLine();
if ( room1.equals("upstairs") )
{
System.out.println( "There are two more rooms, the [bedroom] and the [bathroom] which would you like to go to?" );
System.out.print( "> " );
room2 = keyboard.nextLine();
if ( room2.equals("bedroom") )
{
System.out.println( "Would you like to [sleep] or [turn on the light]? " );
System.out.print("> ");
room3 = keyboard.nextLine();
if ( room3.equals("sleep") )
{
System.out.println("You take a nap." );
}
else if ( room3.equals("turn on the light") )
{
System.out.println("You turn on the light and see a nice bedroom.");
}
}
else if ( room2.equals("bathroom") )
{
System.out.println( "Would you like to [flush the toilet] or [turn on the sink]? " );
System.out.print( "> " );
room3 = keyboard.nextLine();
if ( room3.equals("flush the toilet") )
{
System.out.println( "It is blocked. You need a plunger." );
}
else if ( room3.equals("turn on the sink") )
{
System.out.println("Green goo flows out");
}
}
}
else if ( room1.equals("main hall") )
{
System.out.println( "There are two more rooms, the [kitchen] and the [living room] which would you like to go to?" );
System.out.print( "> " );
room2 = keyboard.nextLine();
if ( room2.equals("kitchen") )
{
System.out.println( "You see a muffin and a cookie." );
System.out.println( "Would you like to [eat the muffin] or [eat the cookie]? " );
System.out.print( "> " );
room3 = keyboard.nextLine();
if ( room3.equals("eat the muffin") )
{
System.out.println( "You eat the muffin and taste poison. You die." );
}
else if ( room3.equals("eat the cookie") )
{
System.out.println( "The cookie tastes funny. I don't think they are chocolate chips... " );
}
}
else if ( room2.equals("living room") )
{
System.out.println( "There is a television and an ipod. " );
System.out.println( "Would you like to [watch television] or [listen to itunes radio]? " );
System.out.print( "> " );
room3 = keyboard.nextLine();
if ( room3.equals("watch televison") )
{
System.out.println( "You begin to watch The Walking Dead." );
}
else if ( room3.equals("listen to itunes radio") )
{
System.out.println( "You listen to the calm radio station." );
}
}
}
}
}
Picture of the output