Assignment #77
Code
/// Name: Ian Stanko
/// Period: 5
/// Program Name: shortadventure2
/// File Name: shortadventure2.java
/// Date Finished: 1/25/2016
public class shortadventure2
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int nextroom = 1;
String response= "";
while ( nextroom!= 0 )
{
if ( nextroom == 1 )
{
System.out.println( "You're in a spooky house. Do you go UP the stairs, or DOWN into the basement?" );
System.out.print( ">" );
response = keyboard.next();
if ( response.equals("DOWN"))
nextroom = 2;
else if ( response.equals("UP"))
nextroom = 3;
else
{
System.out.println( "Error. Not one of the choices." );
}
}
if ( nextroom == 2 )
{
System.out.println( "You go down the stairs and you go into a hallway. There are two doors. One to the LEFT and one to RIGHT? Which one do you go into?");
System.out.print( ">" );
response = keyboard.next();
if ( response.equals("LEFT"))
nextroom = 4;
else if ( response.equals("RIGHT"))
nextroom = 5;
else
{
System.out.println( "ERROR");
}
}
if (nextroom == 3 )
{
System.out.println( "You walk upstairs, but the hallway door is blocked. Do you BREAK the door, or do you go BACK?" );
System.out.print( ">" );
response = keyboard.next();
if (response.equals("BREAK"))
nextroom = 6;
else if (response.equals("BACK"))
nextroom = 1;
else
{
System.out.println( "ERROR");
}
}
if (nextroom == 4)
{
System.out.println( "You go left and you find a closet. That closet turns out to be the closet into Narnia. WOOOHOOOOO> ");
}
if (nextroom == 5)
{
System.out.println( "You walk right and there is a man holding a knife. You can go BACK, or he can KILL you." );
System.out.print( ">" );
response = keyboard.next();
if (response.equals("BACK"))
nextroom = 1;
else
{
System.out.println( "YOU DEAD LMAO!!!!" );
nextroom = 0;
}
}
if (nextroom == 6 )
{
System.out.println( "You break through the door and walk onto a very large platform and there is the huge aircraft carrier from Avengers. You go on to save the world." );
nextroom = 0;
}
}
}
}
Picture of the output HOME