Assignemnt #77 Adventures

Code

    /// Name: Caelan Dorstad
    /// Period: 6
    /// Program Name: Adventure2
    /// File Name: Adventure2.java
    /// Date Finished: 2/19/2016
    
    
    import java.util.Scanner;

    public class Adventure2
    {
    	public static void main( String[] args )
    	{
    		Scanner keyboard = new Scanner(System.in);
    		
    		int nextroom = 1;
    		String choice = "";
    
    		while ( nextroom != 0 )
    		{
    			if ( nextroom == 1 )
    			{
    				System.out.println( "You are in a small house. There is a \"kitchen\" and \"door\"" );
    				System.out.print( "> " );
    				choice = keyboard.nextLine();
    				if ( choice.equals("kitchen") )
    					nextroom = 2;
    				else if ( choice.equals("door") )
    					nextroom = 3;
    				else
    					System.out.println( "ERROR." );
                        System.out.println();
    			}
    			if ( nextroom == 2 )
    			{
    				System.out.println( "There is a cake, would you \"eat\" it or \"leave\" it?" );
    				System.out.print( "> " );
    				choice = keyboard.nextLine();
    				if ( choice.equals("eat") )
    					nextroom = 5;
                    else if ( choice.equals("leave"))
                             nextroom = 4;
    				else
    					System.out.println( "ERROR." );
                        System.out.println();
                }
                
                if ( nextroom == 3)
                {
                    System.out.println("There's nothing. All you can do is go \"back\"");
                    System.out.print("> ");
                    choice = keyboard.nextLine();
                    if (choice.equals("back"))
                        nextroom = 1;
                    System.out.println();
                    
                }
                
                
                
                if (nextroom == 4){
                    System.out.println("You tried not to eat the cake, but since you were starving, you ate it.");
                    System.out.println("The cake smelled weried and tasted funny.");
                    System.out.println("An hour later, you died from food poisoning.");
                    nextroom = 0;
                    System.out.println();
                }
                
                
                if (nextroom == 5){
                    System.out.println("The cake smelled weried and tasted funny.");
                    System.out.println("An hour later, you died from food poisoning.");
                    nextroom = 0;
                }
    	}
            		System.out.println( "\nEND." );
    
        }
    }
            
                               

    

Picture of the output

Assignment 10