Assignment #77 and Adventure2
Code
/// Name: Graham Pollock
/// Period: 5
/// Program Name: Adventure 2
/// File Name: Adventure2.java
/// Date Finished: 01/29/2016/
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 are in a super spooky house. you can either go 'upstairs' or 'downstairs'." );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("upstairs") )
nextroom = 2;
else if ( choice.equals("downstairs") )
nextroom = 3;
else
System.out.println( "ERROR." );
}
if ( nextroom == 2 )
{
System.out.println( "After climbing the stairs there is a dirty room with one stattered window." );
System.out.println( "Do you go 'back' downstairs or try to 'jump' out the window?." );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 1;
else if ( choice.equals("jump"))
nextroom = 4;
else
System.out.println( "ERROR." );
}
if ( nextroom == 3 )
{
System.out.println( "You walk downstairs and find a long hallway with Mark's face painted very");
System.out.println( "accurately on all sides of the hallway. Do you walk 'back' upstairs, or go");
System.out.println( "'down' the hallway?");
choice = keyboard.nextLine();
if ( choice.equals("back"))
nextroom = 1;
else if ( choice.equals("down"))
nextroom = 5;
else
System.out.println( "ERROR." );
}
if ( nextroom == 4 )
{
System.out.println( "The house is on the water and you land safely in the water and swim to freedom.");
nextroom = 0;
}
if ( nextroom == 5 )
{
System.out.println( "the hallway gets progressively janky and by the end the floorboards start to creek as if they are going to break. Do you 'continue' or go 'back'?");
choice = keyboard.nextLine();
if ( choice.equals("continue"))
nextroom = 6;
else if ( choice.equals("back"))
nextroom = 3;
else
System.out.println( "ERROR.");
}
if ( nextroom == 6 )
{
System.out.println( "A secret door opens and you get out safe.");
nextroom = 0;
}
}
System.out.println( "\nEND." );
}
}
Picture of the output