Assignemnt #77 and Adventure 2
Code
///Name: Daniel Tiffany-Appleton
///Period: 7
///Program Name: Adventure 2
///File Name: Adventure2
///Date Finished:1/27/16
import java.util.Scanner;
public class Adventure2
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int nextroom = 1;
String choice = "";
while ( nextroom != 0 )
{
if ( nextroom == 1 )
{
System.out.println( "You see a strange room, you don't know why you are here, but you also you see a dark hallway. Do you \"stay in the room\" or do you \"enter the hallway\"?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("stay in the room") )
nextroom = 2;
else if ( choice.equals("enter the hallway") )
nextroom = 3;
else
System.out.println( "ERROR." );
}
if ( nextroom == 2 )
{
System.out.println( "You choose to stay in the room. In the room you spy a creepy clown doll and a Barbie. What do you go to the \"clown\", the \"Barbie\" or do you turn \"back\"?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("back") )
{
nextroom = 1;
}
else if(choice.equals("clown") )
{
System.out.println( "You go to the clown and pick it up. You turn it around and find a key, then you look up and see a door. You insert the key and open the door to the outside" );
nextroom = 0;
}
else if(choice.equals("Barbie") )
{
System.out.println( "You go to the Barbie. You pick up the Barbie, and as you examine the doll, it starts to release a gas. As the gas fills your lungs, you lose conciousness." );
System.out.println( " " );
nextroom = 1;
}
else
{
System.out.println( "ERROR." );
}
}
else if ( nextroom == 3 )
{
System.out.println( "You decide to enter the dark hallway. At the end of the hallway, you see a room, the exact same room you just left. In this room you see hole in the ground, just big enought for you to fit in, and a another dark hallway. Do you enter the \"hole\", the \"hallway\" or turn \"back\"?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if(choice.equals("hole"))
{
System.out.println( "You decide to jump down the hole. As you continue to drop, you realize that it is taking a long time. Soon you realize that this drop isn't stopping anytime soon, and that you might spend eternity here." );
nextroom = 0;
}
else if(choice.equals("hallway"))
{
nextroom = 3;
}
else if(choice.equals("back"))
{
nextroom = 2;
}
else
{
System.out.println( "ERROR." );
}
}
}
System.out.println( "\nEND." );
}
}
Picture of the output