Assignment 77

code

///Name: Mutsu Osoegawa
///Period: 7
///Project Name: Adventure 2
///File Name: Adventure2.java
///Date: 1/28/2015

import java.util.Scanner;
public class Adventure2
{
    public static void main( String[] args )
    {
        String answer, answer2, answer3;
        int c;
        Scanner keyboard = new Scanner(System.in);
        System.out.println( "Mutsu's Tiny Adventure 2! " );
        System.out.println();
        c = 1;
        do
        {
        System.out.println( "You are in a castle. Two paths await you. Would you like to go left or right. " );
        System.out.print( "> " );
        answer = keyboard.next();
        if ( answer.equals("left") )
        {
            System.out.println( "You are in a gigantic hall. Would you like to go the the \"bedroom\", the \"library\", or go \"back\". " );
            System.out.print( "> " );
            answer2 = keyboard.next();
            if ( answer2.equals("bedroom"))
                {
                    System.out.println( "There is a bed would you like to \"sleep\" or go \"back\". " );
                    System.out.print( "> " );
                    answer3 = keyboard.next();
                    if (answer3.equals("sleep"))
                        {
                            System.out.println( "You fall into a deep slumber. " );
                            c = 0;
                        }
                    else if ( answer3.equals("back"))
                    {
                        c = 1;
                    }
                }
            else if ( answer2.equals("library"))
            {
                System.out.println( "There are many books in the library. Would you like to read a \"book\" or go \"back\". " );
                System.out.print("> ");
                answer3 = keyboard.next();
                if (answer3.equals("book"))
                {
                    System.out.println("You begin reading a book. Consumed in its story. ");
                    c = 0;
                }
                else if (answer3.equals("back"))
                {
                    c = 1;
                }
            }
                         
        }
        else if ( answer.equals("left") )
        {
            System.out.println("You are outside a garden. Would you like to go \"in\" or go \"back\". " );
            System.out.print("> ");
            answer2 = keyboard.next();
            if (answer2.equals("in"))
                {
                    System.out.println("You see a gate on the other side. Seems like the way out. ");
                    c = 0;
                
                }
            else if (answer2.equals("back"))
                     {
                         c = 1;
                     }             
        }
        else 
        {
            c = 1;
        }
        } while ( c != 0 );
    }
}