Assignemnt #77 and Adventure 2
Code
/// Name: Raff Lisbona
/// Period: 6
/// Program Name: Adventure 2
/// File Name: Adventure2.java
/// Date Finished: 12/16/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 on a plane sitting in your seat. Do you go to the \"cockpit\" or to the" );
System.out.println("\"restroom\". Where do you want to go?");
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("cockpit") )
nextroom = 2;
else if ( choice.equals("restroom") )
nextroom = 3;
else
System.out.println( "ERROR." );
}
if ( nextroom == 2 )
{
System.out.println( "The door to the cockpit is locked. Do you \"break\" 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 in and notice that someone left a sandwhich on the counter. Do" );
System.out.println("you \"eat\" it, \"ignore\" it and continue you're business, or go \"back\"");
System.out.println("to your seat?");
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("eat") )
nextroom = 5;
if ( choice.equals("ignore") )
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've starteled the pilot. He sends the plane into" );
System.out.println("a nose dive. The control stick broke and you've doomed everyone on the plane. ");
System.out.println("\nEveryone is dead.");
nextroom = 0;
}
if ( nextroom == 5 )
{
System.out.println( "The sandwhich tastes great but as soon as you finish it your vision starts to" );
System.out.println("go blurry... Now you can't see at all... You feel yourself falling to the ground.");
System.out.println("When you fell you hit your head on the toilet and fracture your skull. You died ");
System.out.println("in an airplane bathroom... that's just sad.");
nextroom = 0;
}
if ( nextroom == 6 )
{
System.out.println( "You ignored the sandwhich and finished your business in the restroom. Good job." );
System.out.println("Now 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