Do-While Loops part 2 #77 (A long game)
Code
/// Name: Amir Salehi
/// Period: 7
/// Program Name:Amirs Adventure2
/// File Name:AmirsAdventure2.java
/// Date Finished: 2/2/2016
import java.util.Scanner;
public class AmirsAdventure2 //Not Finished, Please revise-Me
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int nextroom = 1;
String choice = "";
int key = 0;
int flush = 0;
int flood = 0;
while ( nextroom != 0 )
{
if ( nextroom == 1 )
{
System.out.println( "You are stuck inside a room with a ceiling lamp hanging from above. There is a \"bathroom\" door and a doorway to the \"exit\"." );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("bathroom") && flush < 0)
nextroom = 14;
else if ( choice.equals("bathroom") )
nextroom = 2;
else if ( choice.equals("exit") )
nextroom = 3;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 2 )
{
System.out.println( "You've entered the bathroom, inside you see a \"toilet\", a standing \"shower\", \"covers\" with sink on top and a mirror on the wall. There's nothing to do here except go \"back\"." );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 1;
else if ( choice.equals("toilet") )
nextroom = 5;
else if ( choice.equals("shower") )
nextroom = 6;
else if ( choice.equals("covers") && key > 0) {
System.out.println("You've already searched the covers, not reasoning going back there again.");
nextroom = 2;}
else if ( choice.equals("covers") )
nextroom = 7;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 14 )
{
System.out.println( "You've entered the bathroom, your feet are wet, inside you see a shattered \"toilet\", a standing \"shower\", \"covers\" with sink on top and a mirror on the wall. There's nothing to do here except go \"back\"." );
System.out.print( "> " );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 1;
else if ( choice.equals("toilet") )
nextroom = 13;
else if ( choice.equals("shower") )
nextroom = 6;
else if ( choice.equals("covers") && key > 0){
System.out.println("You've already searched the covers, not reasoning going back there again.");
nextroom = 14;
}
else if ( choice.equals("covers") )
nextroom = 7;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 3 )
{
System.out.println( "There's an illuminated sign above the door entitled \"EXIT\"" );
System.out.println( "The door \"handle\" visible. Behind you is the one room with the ceiling lamp hanging and your chair which is middle of it." );
System.out.println( "Do you want to use the door \"handle\" or go \"back\" ?" );
choice = keyboard.nextLine();
System.out.print( "> " );
if ( choice.equals("back") )
nextroom = 1;
else if ( choice.equals("handle") && key > 0)
nextroom = 9;
else if ( choice.equals("handle") )
nextroom = 4;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 9 )
{
System.out.println( "As you handle reaches toward the handle you grasp the cold chrome colored metal" );
System.out.println( "you insert the key into the lock of the door." );
System.out.println();
System.out.println( "A click noise could be heard, you open the door and a flow of light comes in." );
System.out.println( "The flow of white light is unbearable and it slowly enters the room, until everything surrounding you becomes...." );
System.out.println( "" );
System.out.println( "ERASED.......then.....the.....world...starts...a...new....Chap-/.,`~" );
nextroom = 0;
}
if ( nextroom == 4 )
{
System.out.println( "As you handle reaches toward the handle you grasp the cold chrome colored metal" );
System.out.println( "you jiggle the door handle. It's locked," );
System.out.println();
System.out.println( "There's nothing else you could do, head \"back\"" );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 1;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 5 )
{
System.out.println( "You wander towards the toilet" );
System.out.println( "It's a nice shiny porcelin and not like those ones in a public bathroom" );
System.out.println( "But the ones you see in the royal houses." );
System.out.println();
System.out.println( "On the right a roll of toilet paper hangs from the wall." );
System.out.println( "But....Its.....UNDER HANDED! GAHHHHHH" );
System.out.println( "There's nothing else you could do except \"flush\" the toilet, or head \"back\"" );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 2;
else if (choice.equals("flush") )
nextroom = 10;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 10 )
{
System.out.println( "As you reach for the flush handle you push it down." );
System.out.println( "A loud flushing noise could be heard from the bowl" );
System.out.println( "It made a gulp sound when it finished." );
System.out.println();
System.out.println( "Satisfying sound isn't it?" );
System.out.println( "But uhhh, should you be doing something else important" );
System.out.println( "There's nothing else you could do except \"flush\" the toilet again, or head \"back\"" );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 2;
else if (choice.equals("flush") )
nextroom = 11;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 11 )
{
System.out.println( "As you reach for the flush handle you push it down." );
System.out.println( "A loud flushing noise could be heard from the bowl" );
System.out.println( "It made a gulp sound when it finished." );
System.out.println();
System.out.println( "OK, I get it, you like flushing toilets, I completely understand if that's your type of fetish!" );
System.out.println( "But, come on let's get back to the story here, unless you want to play Toilet Simulator 2016." );
System.out.println( "There's nothing else you could do except \"flush\" the toilet, or head \"back\" (NOTE: If you Flush one more time You'll crash the game" );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 1;
else if (choice.equals("flush") )
nextroom = 12;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 11 )
{
System.out.println( "As you reach for the flush handle you push it down." );
System.out.println( "A loud flushing noise could be heard from the bowl" );
System.out.println( "It made a gulp sound when it finished." );
System.out.println();
System.out.println( "Then the Toilet shatters into pieces, because of constant use of flushing!" );
System.out.println( "Oh no, look like your toilet broke, welp I least you can't flush anymore" );
System.out.println( "There's nothing else you could do except \"flush\" the shattered toilet, or head \"back\"" );
flush++;
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 14;
else if (choice.equals("flush") )
nextroom = 13;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 13 )
{
System.out.println( "The toilet is shattered" );
System.out.println( "You can't flush it no more" );
System.out.println( "It made a gulp sound when it finished." );
System.out.println();
System.out.println( "There's nothing else you could do except \"flush\" the shattered toilet, or head \"back\"" );
choice = keyboard.nextLine();
if ( choice.equals("back") )
nextroom = 14;
else if (choice.equals("flush") )
nextroom = 13;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 6 )
{
System.out.println( "You peak into the shower" );
System.out.println( "The Shower is clean," );
System.out.println( "Aside the shower there are shampoos and conditioners at the side, aswell as a bar of soap and sponge" );
System.out.println();
System.out.println( "There's nothing else you could do except \"shower\", or head \"back\"" );
choice = keyboard.nextLine();
if ( choice.equals("shower") )
nextroom = 15;
else if ( choice.equals("back") && flush < 0)
nextroom = 4;
else if ( choice.equals("back") )
nextroom = 2;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 15 )
{
System.out.println( "You turn the knobs water starts to flow." );
System.out.println( "However" );
System.out.println( "You feel as if you are being watched, might as well not take a shower." );
System.out.println();
System.out.println( "There's nothing else you could do except \"shower\", or head \"back\"" );
choice = keyboard.nextLine();
if ( choice.equals("shower") )
nextroom = 15;
else if ( choice.equals("back") && flush < 0)
nextroom = 4;
else if ( choice.equals("back") )
nextroom = 2;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 7 )
{
System.out.println( "You approached the covers, you try to pull all the drawers, they are locked." );
System.out.print( " " );
System.out.println( "Yet as you reached the last drawer, you feel as if the lock is weak" );
System.out.println( "Do you want to try to \"open\" the last drawer or go \"back\" to the middle of the bathroom?" );
choice = keyboard.nextLine();
if ( choice.equals("back") && flush < 0)
nextroom = 14;
else if ( choice.equals("back") )
nextroom = 2;
else if ( choice.equals("open") )
nextroom = 8;
else
System.out.println( choice + " wasn't one of the options. Try again." );
}
if ( nextroom == 8 )
{
System.out.println( "You give a strong pull." );
System.out.print( " " );
System.out.println( "The lock gives up and there's a key" );
System.out.print( " " );
System.out.println( "You pick up the key and wander back to the center of the bathroom" );
key++;
key++;
if ( flush < 0)
nextroom = 14;
else
nextroom = 2;
}
}
System.out.println( "\nGAME OVER" );
// List to do: Make 4 more rooms, add "key" item, make if statement with key when re-enter the door room with counter
}
}
Picture(s) of the output