Assignemnt #77 and Adventure 2
Code
/// Name: David Shkolnikov
/// Period: 6
/// Program Name: Adventure 2
/// File Name: Adventure2.java
/// Date Finished: 1/27/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're on an abandoned island after a plane crash. Do you go to look for \"food\"" );
System.out.println("or \"shelter\"?");
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("food") )
nextroom = 2;
else if ( choice.equals("shelter") )
nextroom = 3;
else
System.out.println( "ERROR." );
}
if ( nextroom == 2 )
{
System.out.println( "There seems to be no sign of food anywhere. Do you keep\"looking\" or go" );
System.out.println( " \"back?\" to the plane" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("looking") )
nextroom = 4;
if ( choice.equals("back") )
nextroom = 1;
else
System.out.println( "ERROR." );
}
if ( nextroom == 3 )
{
System.out.println( "You are looking for shelter when you come upon a talking group" );
System.out.println("of squirrels who ask if youd like their help, would you like to \"listen\"");
System.out.println("to or \"ignore\" the squirrels");
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("listen") )
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 a hollow tree and find a lifetime supply of DragonFruit" );
System.out.println("It turns out this DragonFruit was actually real Dragon eggs. ");
System.out.println("\nYou die from eating them, RIP.");
nextroom = 0;
}
if ( nextroom == 5 )
{
System.out.println( "They take you to their kingdom and tell you they will heal your wounds from" );
System.out.println("the crash. You eat the herbs they give you and in the next hour you progressively");
System.out.println("feel weaker and weaker until you die. ");
nextroom = 0;
}
if ( nextroom == 6 )
{
System.out.println( "You ignored the squirrels and eventually find a nice shelter where" );
System.out.println("you begin setting up. Now go \"back\" to the plane to retrieve your items.");
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