Assignment #45

Code

/// Name: Kabir Virk
    /// Period: 6
    /// Program Name: Choose Your Own Adventure!
    /// File Name: ChooseAdventure.java
    /// Date Finished: 10/28/2015
    
    import java.util.Scanner;

    public class ChooseAdventure
    {
        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 KABIR'S TINY ADVENTURE!");
            System.out.println();
            System.out.println("You are in a haunted house! Would you like to go to the \"basement\" or to the \"living room\"?");
            r1 = keyboard.next();
            
            System.out.println();
            
            if (r1.equals("basement"))
            {
                System.out.println("You enter the basement and see eyes staring at you. You may go back \"upstairs\" or to grab a baseball bat \"baseball bat\".");
                r2 = keyboard.next();
                
                System.out.println();
                
                if (r2.equals("upstairs"))
                {
                    System.out.println("You go back upstairs. Would you like to leave or stay? (\"leave\" or \"stay\")");
                    r3 = keyboard.next();
                    
                    System.out.println();
                    
                    if (r3.equals("leave"))
                    {
                        System.out.println("You leave the house and stay alive. Thank you for playing!");
                    }
                    else if (r3.equals("stay"))
                    {
                        System.out.println("You get eaten alive. Thank you for playing!");
                    }
                }
                else if (r2.equals("baseball bat"))
                {
                    System.out.println("You get into a fight wiht a green monster. Would you like to attack it or defend yourself (\"attack\" or \"defend\")");
                    r4 = keyboard.next();
                    
                    System.out.println();
                    
                    if (r4.equals("attack"))
                    {
                        System.out.println("You are able to hit him but he gets angry and attacks you. Thank you for playing!");
                    }
                    else if (r4.equals("defend"))
                    {
                        System.out.println("You defend his attacks and strike when he is weak and defeat him. Thank you for playing!");
                    }
                }
            }
            else if (r1.equals("living room"))
            {
                System.out.println("You sit down on the couch. You can turn on the \"tv\" or \"leave\" to find food.");
                r5 = keyboard.next();
                
                System.out.println();
                
                if (r5.equals("tv"))
                {
                    System.out.println("You are watching a show about crayons. Would you like to change the channel? (\"yes\" or \"no\")");
                    r6 = keyboard.next();
                    
                    System.out.println();
                    
                    if (r6.equals("yes"))
                    {
                        System.out.println("Youf find a documentary on penguins and are deeply informed on their history. Thank you for playing!");
                    }
                    else if (r6.equals("no"))
                    {
                        System.out.println("You continue watching how crayons are made. Thank you for playing!");
                    }
                }
                else if (r5.equals("leave"))
                {
                    System.out.println("You get to the fridge. Would you like to open the fridge? (\"yes\" or \"no\")");
                    r7 = keyboard.next();
                    
                    System.out.println();
                    
                    if (r7.equals("yes"))
                    {
                        System.out.println("You find a giant stuffed chicken and devour it. Thank you for playing!");
                    }
                    else if (r7.equals("no"))
                    {
                        System.out.println("You starve to death. Thank you for playing!");
                    }
                }
            }
        }
    }
 

Picture of the output

Assignment 44