Program #44

Code

   
    /// Name: Afaf Nabeeha
    /// Period: 7
    /// Program Name: Choose Your Own Adventure!
    /// File Name: Adventure.java
    /// Date Finished: 11/12/2015 public class Adventure

        import java.util.Scanner;
        public class Adventure
        {
            public static void main( String[] args )
            {
                Scanner keyboard = new Scanner(System.in);
                
                String r1, r2, r3;
                r1 = r2 = r3 = "room";
                System.out.println( "WELCOME TO AFAF'S TINY ADVENTURE!" );
                System.out.println();
                System.out.println( "You are in a creep house! Would you like to go \"upstairs\" or to the \"kitchen\"? " );
                System.out.print( "> " ); 
                r1 = keyboard.nextLine();
                
                if ( r1.equals("kitchen") )
                    {
                       System.out.println( "There is a long countertop with dirty dishes everywhere. Off to one side there is, as you'd expect, a refrigerator. You may open the \"refrigerator\" or look in a \"cabinet\". You may open the \"refrigerator\" or look in a \"cabinet\"?" );
                       System.out.print( "> " );
                        r2 = keyboard.nextLine();
                            
                            if ( r2.equals("refrigerator") )
                            {
                            System.out.println( "Inside the refrigerator you see food and stuff.  It looks pretty nasty. Would you like to eat some of the food? (\"yes\" or \"no\") " );
                            System.out.print("> ");
                            r3 = keyboard.nextLine();
                                
                                if ( r3.equals("no") )
                                {
                                System.out.println("You die of starvation... eventually." );
                                }
                                else if ( r3.equals("yes") )
                                {
                                System.out.println("You reach in and grab a large box. Upon opening it you find cupcakes.  Yum ");
                                }
                            }
                            else if ( r2.equals("cabinet") )
                            {
                            System.out.println( "In the cabinet is a filthy grocery bag and a box of mac and cheese. Would you like to \"open the filthy bag\" or \"eat mac and cheese\"? " );
                            System.out.print( "> " );
                            r3 = keyboard.nextLine();
                                if ( r3.equals("open the filthy bag") )
                                {
                                System.out.println( "As soon as you open the bag, you see a lot of green.  Congratualations, it is a bag filled with hundred dollar bills!" );
                                }
                                else if ( r3.equals("eat mac and cheese") )
                                {
                                System.out.println("You forgot to look at the expiration date.  It expired in 1959.  Whoops! Well, looks like you will not live. How devastating.  ");
                                }
                            } 
                        }
                else if ( r1.equals("upstairs") )
                    {
                    System.out.println( "Upstairs you see a hallway.  At the end of the hallway is the master \"bedroom\".  There is also a \"bathroom\" off the hallway.  Where would you like to go?" );
                    System.out.print( "> " );
                    r2 = keyboard.nextLine();
                        if ( r2.equals("bedroom") )
                        {
                        System.out.println( "You are in a plush bedroom, with expensive-looking hardwood furniture.  The bed is unmade.  In the back of the room, the closet door is ajar.  Would you like to open the door? (\"yes\" or \"no\") " );
                        System.out.print( "> " );
                        r3 = keyboard.nextLine();
                            if ( r3.equals("no") )
                            {
                            System.out.println( "Well, then I guess you'll never know what was in there.  Thanks for playing, I'm tired of making nested if statements." );
                            }
                            else if ( r3.equals("yes") )
                            {
                            System.out.println( "Its completely empty except for the mini trampoline in the middle.  Enjoy!" );
                            }
                        }
                        else if ( r2.equals("bathroom") )
                        {
                        System.out.println( "It is like you have stepped into the bathroom of a millionaire. Its white and gold. Real gold. " );
                        System.out.println( "Would you like to \"take a shower\" or \"use the toilet\"? " );
                        System.out.print( "> " );
                        r3 = keyboard.nextLine();
                            if ( r3.equals("take a shower") )
                            {
                            System.out.println( "There is no hot water.  Shucks." );
                            }
                            else if ( r3.equals("use the toilet") )
                            {
                            System.out.println( "When you flush, the in-bathroom speakers play a great song.  Show off your dance mooves!" );
                            }   
                        }
                    }
            }
        }


                      
    

Picture of the output

Assignment 45