Assignment #77 and Adventure2
Code
/// Name: Jason Kim
/// Period: 7
/// Program Name: Adventure2
/// File Name: Adventure2.java
/// Date Finished:11/19/15
import java.util.Scanner;
public class Adventure2
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int nextroom = 1;
String choice = "";
System.out.println("JASON'S TINY ADVENTURE 2!");
while ( nextroom != 0 )
{
if ( nextroom == 1 )
{
System.out.println( "\nYou are in a creepy house. Would you like to go \"downstairs\" or into the \"kitchen\"?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("downstairs") )
nextroom = 2;
else if ( choice.equals("kitchen") )
nextroom = 3;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 2 )
{
System.out.println( "\nYou went downstairs but found nothing. You have no choice but to go \"back\"." );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 1;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 3 )
{
System.out.println( "\nYou went into the kitchen and found a door and a refrigerator. Would you like to open the \"door\" or the \"refrigerator\"?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("door") )
nextroom = 4;
else if ( choice.equals("refrigerator") )
nextroom = 5;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 4 )
{
System.out.println( "\nYou opened the door. It's raining outside. The air is cold. You find strange light shining from far away, but you can't quite see what it is." );
System.out.println("Do you want to go toward the \"light\" or go \"back\"?");
System.out.print( "> " );
choice = keyboard.nextLine();
if (choice.equals("light"))
{
System.out.println("You go toward the light and find aliens. You suddenly become unconscious, never to wake again.");
nextroom = 0;
}
else if ( choice.equals("back") )
nextroom = 3;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 5 )
{
System.out.println("\nYou opened the refrigerator and found some food. Would you like to eat some of the food?(\"yes\" or \"no\")");
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("yes"))
{
System.out.println("The food is good. As you are eating, a police officer comes in brings you home.");
nextroom = 0;
}
else if ( choice.equals("no"))
nextroom = 6;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if (nextroom == 6 )
{
System.out.println("\nYou closed the refrigerator. There is nothing left to do. Do you want to just \"stand\" there or open the \"refrigerator\" again?");
System.out.print( "> " );
choice = keyboard.nextLine();
if( choice.equals("refrigerator"))
nextroom = 5;
else if ( choice.equals("stand"))
{
System.out.println("You stand there until you die.");
nextroom = 0;
}
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
}
System.out.println( "\nThe game is over. The next episode can be downloaded for only 800 Microsoft points!" );
}
}
Picture of the output