Assignment 77; AdventureBack
Code
// Donovan Rich
// Period 6
// Adventure 2
// AdventureBack.java
// 2/4/16
import java.util.Scanner;
public class AdventureBack
{
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 really neato room. Would you like to go to the 'study' or the 'arcade'?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("study") )
nextroom = 2;
else if ( choice.equals("arcade") )
nextroom = 3;
else
System.out.println( "ERROR." );
}
if ( nextroom == 3 )
{
System.out.println( "You enter the arcade. Do you play 'pacman' or 'bomberman'? Alternatively, you can go 'back' into the room you were in earlier." );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("pacman") )
nextroom = 4;
else if ( choice.equals("bomberman") )
nextroom = 5;
else if ( choice.equals("back") )
nextroom = 1;
else
System.out.println( "ERROR." );
}
if ( nextroom == 2 )
{
System.out.println( "You enter the study. Do you wish to 'study' or 'die'? You may also head 'back' into the previous room." );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("die") )
{
System.out.println( "You die. Your ceased existence is mourned by none." );
nextroom = 0;
}
else if ( choice.equals("study") )
{
System.out.println( "You study, pursue a good education, and develop a fulfilling career. Congratulations.");
nextroom = 0;
}
else if ( choice.equals("back") )
nextroom = 1;
else
System.out.println( "ERROR." );
}
if ( nextroom == 4 )
{
System.out.println( "You play some dank Pacman. Do you want to continue playing ('yes'/'no') or head 'back' the rad room you started out in?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("yes") )
{
System.out.println( "You continue playing. You turn around for just one second and are spooked to death by a pink ghost.");
nextroom = 0;
}
else if ( choice.equals("no") )
{
System.out.println( "You realize your addiction to videogaming has torn your life apart. You back away, and work on getting yourself back on track.");
nextroom = 0;
}
else if ( choice.equals("back") )
nextroom = 1;
else
System.out.println( "ERROR." );
}
if ( nextroom == 5 )
{
System.out.println( "You play an explosive game of Bomberman. Do you want to continue playing ('yes'/'no') or head 'back' the rad room you started out in?" );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("yes") )
{
System.out.println( "You continue playing. The arcade machine explodes and conflagrates you. You die.");
nextroom = 0;
}
else if ( choice.equals("no") )
{
System.out.println( "You realize your addiction to videogaming has torn your life apart. You back away, and work on getting yourself back on track.");
nextroom = 0;
}
else if ( choice.equals("back") )
nextroom = 1;
else
System.out.println( "ERROR." );
}
}
System.out.println( "\nThe End." );
}
}
Picture of the output