Assignment #77

Code

    
    /// Name: Lacey Reese 
    /// Period: 5
    /// Program Name:  ShortAdventure
    /// File Name:  ShortAdventure.java
    /// Date Finished 2/22/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 = "";
            
            System.out.println( "Welcome to Lacey's Second Adventure!!" );
    
    		while ( nextroom != 0 ) {
                
                
    			if ( nextroom == 1 ) 
                {
                    
    				System.out.println("You and your friends are in a creepy house would you like to go \"upstairs\" or \"downstairs\"? " );
    				System.out.print( "> " );
    				choice = keyboard.nextLine();
    				if ( choice.equals("upstairs") ) 
                                       {
    					nextroom = 2;
                    }
    				else if ( choice.equals("downstairs") )
                                       {
    					nextroom = 3;
                    }
    				else {
    					System.out.println( "ERROR." );
                    }
    			}
                
    			else if ( nextroom == 2 ) 
                                       {
                    
    				System.out.println( " You go upstairs and you find a kitchen! And do you take a risk in opening the \"refridgerator\" or do you go \"back\"  ?" );
    				System.out.print( "> " );
    				choice = keyboard.nextLine();
    				if ( choice.equals("back") ) 
                                       {
    					nextroom = 1;
                    }
                    else if ( choice.equals("refridgerator") ) 
                                       {
                        nextroom = 0;
                    }
    				else
                                       {
    					System.out.println( "ERROR." );
                    }
    			}
                
                else if ( nextroom == 3 )
                                       {
                    
                    System.out.println( " You go back downstairs and you get creeped out of the house. Want to go \"back\" in the house? or \"leave\"?" );
                    System.out.print( "> " );
                    choice = keyboard.nextLine();
                    if ( choice.equals("back") )
                    {
                        nextroom = 1;
                    }
                    else if ( choice.equals("leave") ) 
                    {
                        nextroom = 0;
                    }
                }
                
    		}
    
    		System.out.println( "made it out alive" );
    	}
    	
    }

    

    

Picture of the output

// Assignment 77