Assignemnt #77: Adventure 2
Code
/// Name: Kelsey Lieberman
/// Period 5
/// Program Name: Adventure2
/// File Name: Adventure2.java
/// Date Finished: 12/17/2015
import java.util.Scanner;
public class Adventure2
{
public static void main( String[] args ) throws Exception
{
Scanner keyboard = new Scanner(System.in);
int nextroom = 1;
String choice = "";
while ( nextroom != 0 )
{
if ( nextroom == 1 )
{
System.out.println( "\nYou wake up in a dank, unfamiliar, and creepy house! Do you want to go \"upstairs\" or \"downstairs\"?");
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("upstairs") )
nextroom = 2;
else if ( choice.equals("downstairs") )
nextroom = 4;
else
System.out.println( "ERROR." );
}
if ( nextroom == 4 )
{
System.out.println( "\ndownstairs you find a bathroom and another room. Would you like to go in the \"bathroom\" or the other \"room\" or \"back\"?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 1;
else if ( choice.equals("bathroom") )
nextroom = 5;
else if ( choice.equals("room") )
nextroom = 6;
else
System.out.println( "ERROR." );
}
if ( nextroom == 5 )
{
System.out.println( "\nyou walk into the bathroom. it is slippery. Do you want to \"proceed\" or go \"back\"" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 4;
else if ( choice.equals("proceed") )
nextroom = 7;
else
System.out.println( "ERROR." );
}
if ( nextroom == 7 )
{
System.out.println( "\nYou proceed walking into the bathroom and slip, falling onto your head. You die. Do you want to play again? (y/n)" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("y") )
nextroom = 1;
else if ( choice.equals("n") )
nextroom = 0;
else
System.out.println( "ERROR." );
}
if ( nextroom == 6 )
{
System.out.println( "\nYou walk into the room and the door closes behind you. It is pitch black. It is spooky. Do you want to turn on the \"light\" or go \"back\"?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 4;
else if ( choice.equals("light") )
nextroom = 8;
else
System.out.println( "ERROR." );
}
if ( nextroom == 8 )
{
System.out.println( "\nYou turn on the light, and the room becomes less dank. There is a bed, you are tired. Do you want to \"sleep\" or walk \"back\" out of the room?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 4;
else if ( choice.equals("sleep") )
nextroom = 9;
else
System.out.println( "ERROR." );
}
if ( nextroom == 9 )
{
System.out.println( "\nYou fall alseep. When you wake up, the room is dark again, so you turn on the lights and..." );
Thread.sleep(1000);
System.out.println( "YOU HAVE BEEN SPOOKED BY MR. SKELTAL!!1!111!" );
Thread.sleep(500);
System.out.println( "You feel your bones aching..." );
Thread.sleep(1200);
System.out.println("You die from calcium deficiency! Do you want to play again? (y/n)");
System.out.print("> ");
choice = keyboard.nextLine();
if ( choice.equals("y") )
nextroom = 1;
else if ( choice.equals("n") )
nextroom = 0;
else
System.out.println( "ERROR." );
}
if ( nextroom == 2 )
{
System.out.println( "\nUpstairs you find a pile of bananas! Would you like to \"eat\" one or go \"back\"?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 1;
else if ( choice.equals("eat") )
nextroom = 3;
else
System.out.println( "ERROR." );
}
if ( nextroom == 3 )
{
System.out.println( "\nYou eat the banana and die! awww man! Do you want to play again? (y/n)" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("y") )
nextroom = 1;
else if ( choice.equals("n") )
nextroom = 0;
else
System.out.println( "ERROR." );
}
}
System.out.println( "\nEND." );
}
}
Picture of the output