Assignment #Project
Code
/// Name: Tim Chuang
/// Period: 7
/// Program Name: Project
/// File Name: Project1.java
/// Date Finished: 12/4/2015
import java.util.Scanner;
class Project1
{
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 the Spooky Haus" );
System.out.println();
System.out.println( "You are in a spooky house, would you like to go [upstairs], to the [main hall], or [basement]? " );
System.out.print( "> " );
room1 = keyboard.nextLine();
if ( room1.equals("upstairs") )
{
System.out.println( "You see two 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 [use the flashlight]? " );
System.out.print("> ");
room3 = keyboard.nextLine();
if ( room3.equals("sleep") )
{
System.out.println("You go to sleep." );
}
else if ( room3.equals("use the flashlight") )
{
System.out.println("It is bright.");
}
}
else if ( room2.equals("bathroom") )
{
System.out.println( "Would you like to [flush the toilet] or [turn on the water]? " );
System.out.print( "> " );
room3 = keyboard.nextLine();
if ( room3.equals("flush the toilet") )
{
System.out.println( "The toilet flushes." );
}
else if ( room3.equals("turn on the water") )
{
System.out.println("Blood comes out of the faucet");
}
}
}
else if ( room1.equals("main hall") )
{
System.out.println( "You spot two rooms, the [kitchen] and the [living room] where do you go?" );
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( "It tastes good." );
}
else if ( room3.equals("eat the cookie") )
{
System.out.println( "lol the cookie was poisoned. u lose " );
}
}
else if ( room2.equals("living room") )
{
System.out.println( "There is a television and an ipod. " );
System.out.println( "Would you like to [watch tv] or [browse dank memes]? " );
System.out.print( "> " );
room3 = keyboard.nextLine();
if ( room3.equals("watch televison") )
{
System.out.println( "You watch the Kardashians." );
}
else if ( room3.equals("browse dank memes") )
{
System.out.println( "The memes are too dank. You die." );
}
}
}
else if ( room1.equals("basement") )
{
System.out.println( "You see two doors, one [left] the other on the [right]. Where do you go?" );
System.out.print( "> " );
room2 = keyboard.nextLine();
if ( room2.equals("left") )
{
System.out.println( "You see a barrel and an old book. Do you [kick] the barrel or [read]? " );
System.out.print("> ");
room3 = keyboard.nextLine();
if ( room3.equals("kick") )
{
System.out.println("The barrel gets kicked over and snakes come out." );
}
else if ( room3.equals("read") )
{
System.out.println("You are filled with Nietzche's knowledge and become a dark lord.");
}
}
else if ( room2.equals("right") )
{
System.out.println( "You see a safe. Do you [look] for lasers or [walk] to the safe? " );
System.out.print( "> " );
room3 = keyboard.nextLine();
if ( room3.equals("look") )
{
System.out.println( "You find several lasers, avoid them, and retrieve the treasure." );
}
else if ( room3.equals("walk") )
{
System.out.println("You get killed by lasers.");
}
}
}
}
}
Picture of the output