Assignment #45 and Choose Your Own Adventure

Code

    ///Name: Tim Gibson
    ///Period: 6
    ///Project Name: Choose Your Own Adventure
    ///File Name: CYOA1.java
    ///Date Finished: 10/7/15
        
    import java.util.Scanner;
    
    public class CYOA1
    {
        public static void main ( String[] args ) 
        {
            Scanner keyboard = new Scanner(System.in);
            
            String r2, r3, r5, r6;
            
            System.out.println( "WELCOME TO TIMMY'S TINY ADVENTURE!" );
            System.out.println( "\nYou are in a creepy house on a dark and stormy night. Would you like to go \"upstairs\" or into the \"basement\"?" );
            r2 = keyboard.next();
            
            if ( r2.equals("upstairs"))
            {
                System.out.println( "\nYou find yourself in a hallway with two doors. One is open and leads into a bathroom. The other is closed. Do you \"open\" the closed door, or go into the \"bathroom\"?" );
                r3 = keyboard.next();
                
                if ( r3.equals("open"))
                {
                    System.out.println( "\nAhead of you you see only darkness. Do you \"step\" into the darkness, or do you close the door and \"leave\"?" );
                   r5 = keyboard.next();
                    
                    if ( r5.equals("step"))
                    {
                        System.out.println( "\nYou step outside and into thin air, and then fall to your death.");
                    }
                    else if ( r5.equals("leave"))
                    {
                    System.out.println( "\nYou leave the house and safely go home. This time." );
                    }
                }
                else if ( r3.equals("bathroom"))
                {
                    System.out.println( "\nYou walk into the bathroom and see that the shower curtain is closed. Do you \"open\" the shower curtain, or \"leave\" it closed?" );
                    r6 = keyboard.next();
                    
                    if ( r6.equals("open"))
                    {
                        System.out.println( "\nYou see that someone has left the water running and turn it off, saving the homeowner hundreds of dollars. The homeowner comes home, and as a thank you for saving them this money, gives you $100." );
                    }
                    else if ( r6.equals("leave"))
                    {
                        System.out.println( "\nYou leave the house and safely go home. This time." );
                    }
                }
    
            }
            else if ( r2.equals("basement"))
            {
                System.out.println( "\nAs you look around the basement, you see two things. The first is a TV, with a remote lying on the table next to it. The second is a closed door off to the side of the basement. Do you go to the \"TV\", or open the \"door\"?" );
                r3 = keyboard.next();
                
                if ( r3.equals("TV"))
                {
                    System.out.println( "\nDo you want to turn the TV on? ( \"yes\" or \"no\")" );
                    r5 = keyboard.next();
                    
                    if ( r5.equals("yes"))
                    {
                        System.out.println( "\nYou turn on the TV, watch Monday Night Football, and die of despair as you see Colin Kaepernick destroy any chances the 49ers have of having a winning season this year." );
                    }
                    else if ( r5.equals("no"))
                    {
                        System.out.println( "\nYou die of anxeity because you never got to know who won Dancing With the Stars, since you didn't turn on the TV." );
                    }
                }
                else if ( r3.equals("door"))
                {
                    System.out.println( "\nAfter you open the door, you see only darkness, and hear a noise. Do you want to turn the light on in order to find out what the noise was? (\"yes\" or \"no\")" );
                    r6 = keyboard.next();
                    
                    if ( r6.equals("yes"))
                    {
                        System.out.println( "\nYou turn on the light and discover a cat. You take the cat home, and it befriends you, and you have it for the next ten years." );
                    }
                    else if ( r6.equals("no"))
                    {
                        System.out.println( "\nYou leave and safely  return home. This time" );
                    }
                }
            }
        }
    }
        

Picture of the output

Assignment45