Assignemnt #77
Code
/// Name: Sam Menar
/// Period: 6
/// Program Name: Adventure 2
/// File Name: Adventure2.java
/// Date Finished: 2/1/2015
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 room sitting in a chair. Do you get up to go to the \"door\" or to the" );
System.out.println("\"window?\"");
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("door") )
nextroom = 2;
else if ( choice.equals("window") )
nextroom = 3;
else
System.out.println( "ERROR." );
}
if ( nextroom == 2 )
{
System.out.println( "The door is locked. Do you \"break\" it to go through or go \"back?\"" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("break") )
nextroom = 4;
if ( choice.equals("back") )
nextroom = 1;
else
System.out.println( "ERROR." );
}
if ( nextroom == 3 )
{
System.out.println( "You walk up to the window to see a strange man across the street looking at you." );
System.out.println("Do you continue to \"watch\" the man, \"open\" the window to go outside, or");
System.out.println("do you go \"back?\"");
System.out.println("to your seat?");
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("watch") )
nextroom = 5;
if ( choice.equals("open") )
nextroom = 6;
if ( choice.equals("back") )
nextroom = 1;
else
System.out.println( "ERROR." );
}
if ( nextroom == 4 )
{
System.out.println( "You bust open the door but you run into a pack of wild wolves who eat you." );
System.out.println("\nYou are dead.");
nextroom = 0;
}
if ( nextroom == 5 )
{
System.out.println( "The man sees you and gets offended because its 2016 and everything in 2016 is" );
System.out.println( "offensive to somebody. Anyways, he gets offended and kills you with his laser vision" );
nextroom = 0;
}
if ( nextroom == 6 )
{
System.out.println( "You ignored the man. Good job. You're still alive so that's good. Now");
System.out.println( "go \"back\" to your seat." );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 1;
else
System.out.println( "ERROR." );
}
}
System.out.println( "\nEND." );
}
}
Picture of the output