Assignemnt #45, Choose Your Own Adventure.

Code

/// Name: Alex Pinder
/// Period: 5
/// Program Name: Choose Your Own Adventure!
/// File Name: prog45.java
/// Date Complete: 11/17/15

import java.util.Scanner;

public class prog45
{
    public static void main( String[] args )
    {
        Scanner keyboard = new Scanner(System.in);
        
        String R1, R2, R3, R4, R5, R6, R7;
        
        System.out.println( "WELCOME TO ALEX'S MINI ADVENTURE!\n \nYou wake up to find yourself in a room with only a window and a door. Would you like to jump out the \"window\" or go through the \"door\"?" );
        R1 = keyboard.next();
        
        if ( R1.equals("window") )
        {
            System.out.println( "You jump out the window. With nothing to break your fall you inevitably break you leg. You see that you can either take the \"road\" or go through the \"gate\" to the back of the house. Where will you go?" );
            R2 = keyboard.next();
            
            if ( R2.equals("road") )
            {
                System.out.println( "You take the road to find a forest. Do you go into the \"forest\" or \"continue\" on the road?" );
                R4 = keyboard.next();
                
                if ( R4.equals("forest") )
                {
                    System.out.println( "You enter the forest and, without any prior outdoors experience, starve to death.\nTHE END!" );
                }
                
                else if ( R4.equals("continue") )
                {
                    System.out.println( "You are struck by a truck because you weren't paying attention.\nTHE END!" );
                }
            }
            
            else if ( R2.equals("gate") )
            {
                System.out.println( "You enter the gate to see a propane stove and some bundle of wire. Do you investigate the \"wire\" or investigate the \"stove\"?" );
                R5 = keyboard.next();
                
                if ( R5.equals("wire") )
                {
                    System.out.println( "You touch the wire and get electricuted to death.\nTHE END!" );
                }
                else if ( R5.equals("stove") )
                {
                    System.out.println( "The stove turns out to be very sensitive to touch. The instant you touch it it explodes causing you to lose a few limbs and bleed to death.\nTHE END!" );
                }
            }
        }
        else if ( R1.equals("door") )
        {
            System.out.println( "You find yourself in a room with some stairs to a loft and an empty fireplace. Do you go to the \"fireplace\" or go up to the \"loft\"?" );
            R3 = keyboard.next();
            
            if ( R3.equals("fireplace") )
            {
                System.out.println( "You go over to the fireplace. Do you \"light\" it or do you \"leave\" it?" );
                R6 = keyboard.next();
                
                if ( R6.equals("light") )
                {
                    System.out.println( "You light the fireplace but end ub lighting the whole room on fire.\nTHE END!" );
                }
                
                else if ( R6.equals("leave") )
                {
                    System.out.println( "You slowly but eventually freeze to death over the cold night ahead.\nTHE END!" );
                }
            }
            
            else if ( R3.equals("loft") )
            {
                System.out.println( "You see a ladder up to the roof and something that looks a lot like gold out of the corner of your eye. Do you \"investigate\" the gold or go up the \"ladder\"?" );
                R7 = keyboard.next();
                
                if ( R7.equals("invesitgate") )
                {
                    System.out.println( "Just as you were going to look at what seems like gold a trapdoor opens under you. You fall to your death.\nTHE END!" );
                }
                
                else if ( R7.equals("ladder") )
                {
                    System.out.println( "You decide it is best to go up the ladder. On the roof you find yourself in a test chamber. A scientist working tells you that you have been the test subject of their most recent experiment. You are now free!\nTHE END!" );
                }
            }
        }
        
        System.out.println( "Thank you for playing my game!" );
    }
}   
    

Picture of the output

Assignment 45