Assignment = Short Adventure 2

Code

  /// Name: Sam Wilson
  /// Period: 6
  /// Program Name: Short Adventure 2
  /// File Name: adv2.java
  /// Date Finished: 2/15/16

 

 import java.util.Scanner;

public class adv2
{
	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( "Welcome Cadet, you are in space you can either roam the galaxy in your ship, or explore the planet. " );
                System.out.println("Your two options are: '/ship'/ or '/planet'/.");
				System.out.print( "> " );
				choice = keyboard.nextLine();
				
                if ( choice.equals("ship") )
					nextroom = 2;
				
                else if ( choice.equals("planet") )
					nextroom = 3;
				
                else
				System.out.println( "ERROR. Reseting from last point" );
			}
			if ( nextroom == 2 )
			{
				System.out.println( "As you travel through the galaxy you spot what looks like a blackhole and a planet with some sort of purple aura emmiting from it." );
                System.out.println("Your options are: '/land'/ /'black hole'/ or '/back'/");
				System.out.print( "> " );
				choice = keyboard.nextLine();
				if (choice.equals("back") )
					nextroom = nextroom - 1;
				
                else if (choice.equals("black hole"))
                
                    nextroom = 4;
                
                else if (choice.equals("land"))
                nextroom = 5;
                
                else
				System.out.println( "ERROR." );
			}
		    if (nextroom == 4)
            {
                System.out.println("You take your ship through the black hole and land on a planet that looks to be inhabited by apes. You look around the realize that there are other humans however they are treated like animals to the civilized apes. Do you run away towards the wild or do you hide and investigate?");
                System.out.println("Your options are: '/run'/ '/hide'/ or '/back'/");
                System.out.print( "> " );
				choice = keyboard.nextLine();
                if (choice.equals("run") )
                {
                    System.out.println("You run into the wild and live among your fellow primative human beings, your like tarzan without the apes.");
                nextroom = 0;
                }
               else if (choice.equals("hide") ) 
               {
                   
                    System.out.println("You attempt to hide and investigate, however, an ape catches you and you become a worker human");
                    nextroom = 0;
               }
                
                
                else if (choice.equals("back") ) 
                {
                nextroom = nextroom - 2;
                }
                
                
                
                
                
                else 
                System.out.println( "ERROR." );
            }
            if (nextroom == 5)
            {
                System.out.println("You have landed on the unknown planet as you look around you see that there are tons of little candies everywhere and a small broken down cottage");
                System.out.println("Your options are: '/eat'/ '/cottage'/ or '/back'/");
                System.out.print( "> " );
				choice = keyboard.nextLine();
                if (choice.equals("cottage") )
                    System.out.println("You move forward and notice a witch up ahead taking. You take your laser gun and kill the witch, 2 children are in her cottage whom you take home and win a reward prize.");
                nextroom = 0;
                
                if (choice.equals("eat") )
                {
                    System.out.println("You sit down and gorge on the massive amounts of candy, then you fall asleep and wake up to find you are locked up getting ready to be cooked by a witch. After days of agony she finally takes mercy and consumes your fat body.");
                    nextroom = 0;
                }
                
                else if (choice.equals("back") ) 
                {
               nextroom = nextroom - 3;
                }
                
                
                else 
                {
                System.out.println( "ERROR." );
                }
                    
            }
            if (nextroom == 3)
            {
                System.out.println("You decide to explore the planet. It is filled with sand and weird purple stone. The sun radiates a blue wave through the sky. As you look around you notice 2 things, you notice a cave made of diamonds and a sort of tower standing up out of the sand.");
                System.out.println("Your options are: '/tower'/  '/cave'/ or '/back'/ ");
                System.out.print( "> " );
				choice = keyboard.nextLine();
                
                if (choice.equals("tower") )
                 nextroom = 6;
                
                else if (choice.equals("cave"))
                nextroom = 7;
                    
                else if (choice.equals("back") ) 
                {
                System.out.println("");
                   nextroom = nextroom - 2;
                }   
                                        

               
            }
            while (nextroom == 6)
            {
                System.out.println("You go into the tower you. There is a faint cry for help below. You can go up or down.");
                System.out.println("Your options are: '/up'/ '/down'/ or '/back'/");
                System.out.print( "> " );
				choice = keyboard.nextLine();
                
                if (choice.equals("up") )
                {
                System.out.println("You go up and as you watch the beautiful sun set you are pushed out of the tower by a hooded figuire hitting and the ground and dying.");
                 nextroom = 0;
                }
                else if (choice.equals("down"))
                {
                System.out.println("You go down and see a princess as you untie her she then takes out her .44 and shoots a hooded figuire. She thanks you and proceeds to curb stomp the hooded figuire you get married and later divorced taking half your kingdom under your possession.");
                nextroom = 0;
                }
                else if (choice.equals("back") ) 
                {
                
                    nextroom = nextroom - 3;
                }   
                else 
                {
                System.out.println("ERROR");
                }
                
            }
            while (nextroom == 7)
            {

                System.out.println("You go into the cave and at the end see and old man.");
                System.out.println("Your options are: '/leave'/ '/talk'/ or '/back'/ ");
                System.out.print( "> " );
				choice = keyboard.nextLine();
                
                if (choice.equals("talk") )
                {
                System.out.println("The old man says your the first to talk to him, he rewards you by giving you five golden eggs that will hatch golden dragons which are very profitable.");
                 nextroom = 0;
                }
                else if (choice.equals("leave"))
                {
                System.out.println("You leave and get shot down by space raiders. Pretty boring death if you ask me");
                nextroom = 0;
                }
                
                else if (choice.equals("back") ) 
                {
                nextroom = nextroom - 4;
                }   
                
                else 
                {
                System.out.println("ERROR");
                }
            
            }
            
                         
                         
                    
                  
        
                
        
        
        
        
        
        
        }
        

		System.out.println( "\nEND." );
	}
	
}

                    
         
                


    

Picture of the output

Assignment 31