Assignemnt #77 Short Adventure 2: With a Loop

Code

import java.util.Scanner;

public class Adventure2
{
	public static void main( String[] args )
	{
		Scanner keyboard = new Scanner(System.in);
		
		int nextroom = 1,wait,score=1;
		String choice = "";
        boolean polew= true,pole=false,rosew=true,rose=false,fish=false,fishw=true,branchw=true,branch=false, troll=true,crown=false,ghost=true.guard=true,candle=false,candlew=true,r1=false,r2=false,r3=false,r4=false,r5=false,r6=false,r7=false,r8=false,r9=false,r10=false,r11=false,r12=false,r13=false;

		while ( nextroom != 0 )
		{
			if ( nextroom == 1 )
			{
                if (r1==false)
                {
                    r1=true
                    score=score+2
                }
				System.out.println( "You are standing in a small cottage. There is a fishing pole here." );
				System.out.println( "Exits are: Out" );
				System.out.print( "> " );
				choice = keyboard.nextLine();
				if ( choice.equals("Go Out") )
					nextroom = 2;
				else if ( choice.equals("fishing pole")|| polew == true)
                {
					pole = true;
					polew = false;
                    score=score+5;
                }
				else
					System.out.println( "Sorry i don't understand "+choice+"." );
			}
			if ( nextroom == 2 )
			{
                if (r2==false)
                {
                    r2=true
                    score=score+2
                }
				System.out.println( "You are standing on a lush garden path. There is a rosebush here. There is a cottage here." );
				System.out.println( "Exits are: North, South, In" );
				System.out.print( "> " );
				choice = keyboard.nextLine();
				if ( choice.equals("Go In") )
					nextroom = 1;
				else if ( choice.equals("Go North") )
					nextroom = 4;
				else if ( choice.equals("Go South") )
					nextroom = 3;
				else if ( choice.equals("Go South")|| rosew== true )
                {
                    rose = true;
					rosew = false;
                    score=score+5;
                }
                else
					System.out.println( "ERROR." );
			}
            if ( nextroom == 3 )
			{
                if (r3==false)
                {
                    r3=true
                    score=score+2
                }
				System.out.println( "You are at the edge of a small fishing pond." );
				System.out.println( "Exits are: North" );
				System.out.print( "> " );
				choice = keyboard.nextLine();
				if ( choice.equals("Go North") )
					nextroom = 2;
				else if ( choice.equals("fish")|| fishw == true)
                {
                    
                	fish = true;
					fishw = false;
                    score=score+5;
				}
                else
					System.out.println( "Sorry i don't understand "+choice+"." );
			}
            if ( nextroom == 4 )
			{
                if (r4==false)
                {
                    r4=true
                    score=score+2
                }
				System.out.println( "You are walking down a winding path. There is a tall tree here." );
				System.out.println( "Exits are: South, East, Up" );
				System.out.print( "> " );
				choice = keyboard.nextLine();
				if ( choice.equals("Go South") )
					nextroom = 2;
				else if ( choice.equals("Go East") )
					nextroom = 6;
				else if ( choice.equals("Go Up") )
					nextroom = 5;
				else
					System.out.println( "Sorry i don't understand "+choice+"." );
			}
            if ( nextroom == 5 )
			{
                if (r5==false)
                {
                    r5=true
                    score=score+2
                }
				System.out.println( "You are the top of the tree. There is a stout dead branch here." );
				System.out.println( "Exits are: Down" );
				System.out.print( "> " );
				choice = keyboard.nextLine();
				if ( choice.equals("Go Down") )
					nextroom = 4;
				else if ( choice.equals("fish")|| branchw == true)
                {
					branch = true;
					branchw = false;
                    score=score+5;
                }
                else
					System.out.println( "Sorry i don't understand "+choice+"." );
			}
            if ( nextroom == 6 )
			{
                if (r6==false)
                {
                    r6=true
                    score=score+2
                }
				System.out.println( "You are standing on one side of a drawbridge leading to ACTION CASTLE. There is a troll here" );
				System.out.println( "Exits are: West, East" );
				System.out.print( "> " );
				choice = keyboard.nextLine();
				if ( choice.equals("Go West") )
					nextroom = 4;
				else if ( choice.equals("Go East")|| troll == true)
					System.out.println("the troll blockes you path");
				else if ( choice.equals("Go East"))
					nextroom = 7;
				else if ( choice.equals("troll")|| fish == true||troll==true)
                {
                    troll = false;
					fish = false;
                    score=score+10
                    System.out.println( "the troll takes your fish and walks away" );
                }
				else
					System.out.println( "Sorry i don't understand "+choice+"." );
			}
			if ( nextroom == 7 )
			{
                if (r7==false)
                {
                    r7=true
                    score=score+2
                }
				System.out.println( "You are in the courtyard of ACTION CASTLE. There is a guard here, blocking the path east." );
				System.out.println( "Exits are: West, East, Up, Down" );
				System.out.print( "> " );
				choice = keyboard.nextLine();
				if ( choice.equals("Go East")||guard==false )
					nextroom = 12;
				else if ( choice.equals("Go East")||guard==true )
					System.out.print( "the guard blocks your path" );
				else if ( choice.equals("up")||door==false )
					nextroom = 8;
				else if ( choice.equals("up"))
					nextroom = 9;
				else if ( choice.equals("down")||light==false )
					nextroom = 10;
				else if ( choice.equals("down"))
					nextroom = 11;
				else if ( choice.equals("West"))
					nextroom = 6;
				else if ( choice.equals("guard")|| branch==true)
                {
                    
                	guard=false
                    branch=false
                    key=true
                    score=score+15;
                    System.out.print( "you knock out the guard and get a key" );
                }
                else
					System.out.println( "Sorry i don't understand "+choice+"." );
			}
			if ( nextroom == 8 )
			{
                if (r8==false)
                {
                    r8=true
                    score=score+2
                }
				System.out.println( "You are climbing the stairs to the tower. There is a locked door here." );
				System.out.println( "Exits are: Down, Up" );
				System.out.print( "> " );
				choice = keyboard.nextLine();
				if ( choice.equals("Go Down") )
					nextroom = 7;
				else if ( choice.equals("Go Up")||door==false)
				    System.out.print( "The Door is locked" );
				else if ( choice.equals("Go Up"))
					nextroom = 9;				    
				else if ( choice.equals("door") ||key==true)
                {	
                    door = true;
                    System.out.print( "You unlock the door" );
                }
                else
					System.out.println( "Sorry i don't understand "+choice+"." );
			}
			if ( nextroom == 9 )
			{
                if (r9==false)
                {
                    r9=true
                    score=score+2
                }
				System.out.println( "You are inside a tower. The princess is here" );
				System.out.println( "Exits are: Down" );
				System.out.print( "> " );
				if ( crown==true )
                {   
					System.out.print( "The princess takes the crown and puts it on your head." );	
                    hat==true;
                }   
				choice = keyboard.nextLine();
				if ( choice.equals("Go Down") )
					nextroom = 7;				    
				else if ( choice.equals("princess") ||rose==true)
                {
                    score=score+5;
					gave = true;
                    rose=false;
                    System.out.print( "You give the rose to the princess, she says that her father haunts the dungon, and only the rightful heir can wear the crown" );
                }
				else
					System.out.println( "Sorry i don't understand "+choice+"." );
			}
			if ( nextroom == 10 )
			{
                if (r10==false)
                {
                    r10=true
                    score=score+2
                }
				System.out.println( "You are climbing the stairs down to the dungeon. It is too dark to see!" );
				System.out.println( "Exits are: Down, Up" );
				System.out.print( "> " );
				choice = keyboard.nextLine();
				if ( choice.equals("Go Up") )
					nextroom = 7;
				if ( choice.equals("Go Down")||light==false)
				    System.out.print( "It is too dark to see!" );
				if ( choice.equals("Go Down")||light==true)
					nextroom = 11;				    
				else if ( choice.equals("light"))
                {
                    
                	light = true;
                    System.out.print( "You light your lamb" );
                }
                else
					System.out.println( "Sorry i don't understand "+choice+"." );
			}
			if ( nextroom == 11 )
			{
                if (r11==false)
                {
                    r11=true
                    score=score+2
                }
				System.out.println( "You are in the dungeon. There is a spooky ghost here." );
				System.out.println( "Exits are: Up" );
				System.out.print( "> " );
				choice = keyboard.nextLine();
                wait = 0;
				if ( choice.equals("Go Up") )
					nextroom = 7;
				if ( choice.equals("light")||candle==false)
                {
                    System.out.print( "light what?" );
                    wait++;
                }
                if ( choice.equals("light")||ghost==true)
                {
				    System.out.print( "You light the candle and it gives off a acrid-smellinjg smoke." );
				    System.out.print( "The ghost drops its crown and flees." );
                    ghost=false
                    score=score+10
                }
				else if ( choice.equals("crown"))
                {
					crown = true;
                    score=score+5;
                    System.out.print( "You pick up the crown" );
                }
				else
                {
					System.out.println( "Sorry i don't understand "+choice+"." );
                    wait++;
                    if(wait=5|ghost==true)
                    {
                        System.out.println("The ghost reaches out his hand into your chest stopping your heart");
                        nextroom==0
                    }
                }
			}
			if ( nextroom == 12 )
			{
                if (r12==false)
                {
                    r12=true
                    score=score+2
                }
				System.out.println( "You are Great Feasting Hall. There is a Strange candle here." );
				System.out.println( "Exits are: West, East" );
				System.out.print( "> " );
				choice = keyboard.nextLine();
				if ( choice.equals("Go West") )
					nextroom = 7;
				else if ( choice.equals("Go East"))
					nextroom = 13;				    
				else if ( choice.equals("candle") ||candlew==true)
                {
					candle = true;
                    score=score+5;
                    System.out.print( "You take the candle" );
                }
                else
					System.out.println( "Sorry i don't understand "+choice+"." );
			}
			if ( nextroom == 13 )
			{
                if (r13==false)
                {
                    r13=true
                    score=score+2
                }
				System.out.println( "This is the throne room of ACTION CASTLE. There is an ornate golden throne here." );
				System.out.println( "Exits are: West" );
				System.out.print( "> " );
				choice = keyboard.nextLine();
                if (hat==true)
                    System.out.print( "The throne room is full of courtiers, guards and other sunjects/" );
				if ( choice.equals("Go West") )
					nextroom = 12;    
				else if ( choice.equals("throne") ||hat==true)
                {
                    System.out.print( "You Sit on the ornate golden Throne. The people cheer for the new ruler of..." );
                    System.out.print( "ACTION CASTLE" );
                    score=score+5
                    nextroom= 0
                }
				else
					System.out.println( "Sorry i don't understand "+choice+"." );
			}
		}

		System.out.println( "The game is over. You got a score of "+score+" out of 100." );
	}
	
}


    

Picture of the output