Problem getting game to end correctly
<p>here is the code that im have problems getting to work.  </p>

<pre><code>public void fight (Graphics canvas, int fightcount,int curloc)
{

    if(curloc==10)
    {
        fightcount=fightcount-1;
    }
    else if (curloc==10 &amp;&amp; fightcount==0)
    {
        JOptionPane.showMessageDialog(null, "You Win!");
    }
}
</code></pre>

<p>here is the rest of the code  </p>

<pre><code>import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.applet.Applet;

import java.applet.*;
import java.awt.image.*;
import java.util.*;
import java.net.*;
public class AlcatrazEscape extends JApplet implements KeyListener, FocusListener
{
    int strength=0, health=100, curloc=1,randomnumber=0,fightcount=10;
    boolean focus = false;
    boolean left=false, right=false, up=false, down=false, space=false, enter=false;
    boolean start=false,train=false,showers=false,CBC=false,tunnel=false,SecRoom1=false,SecRoom2=false,courtyard=false,fight=false,free=false,GP=false,SolCon=false;
    boolean key1=false, key2=false;

    public void init()
    {

        addKeyListener(this);
        addFocusListener(this);
        play(getCodeBase(), "SpyHunter.mid");

    }
    public void paint(Graphics canvas)
    {
        clearScreen(canvas);

        canvas.setColor(Color.BLACK);  // Must do this so words will
                                       // display on the screen

         if (!focus)
         {
            canvas.setColor(Color.WHITE);
            canvas.drawString("Welcome to Alcatraz Breakout! The objective of the game is to escape Alcatraz.",10,10);
            canvas.drawString("Click the screen to begin the game.",10,30);
            return;
         }
         else
         {
             makeMove(canvas);
             dispLoc(canvas);
             stats(canvas);
             randomnumber=randomnum();
             ran(randomnumber,curloc,canvas);
             health(canvas, health);
             fight(canvas, curloc, fightcount);
             System.out.println(fightcount);
             left=right=up=down=space=enter=false;
         }


    }
    public void room1(Graphics canvas)
    {
        canvas.setColor(Color.WHITE);
        canvas.drawString("You are in your cell.", 10, 10);
        canvas.drawString("Left: To the Training Room", 10, 30);
        canvas.drawString("Right: To the Showers", 10, 50);

    }
    public void room2(Graphics canvas)
    {
        canvas.setColor(Color.WHITE);
        canvas.drawString("You are in the Training Room.", 10, 10);
        canvas.drawString("Right: To your Cell", 10, 30);
    }
    public void room3(Graphics canvas)
    {
        canvas.setColor(Color.WHITE);
        canvas.drawString("You are in the Showers.", 10, 10);
        canvas.drawString("Left: To your Cell", 10, 30);
        canvas.drawString("Up: To Cell Block C", 10, 50);
    }
    public void room4(Graphics canvas)
    {
        canvas.setColor(Color.WHITE);
        canvas.drawString("You are in Cell Block C.", 10, 10);
        canvas.drawString("Down: To the Showers", 10, 30);
        canvas.drawString("Up: To Security Room 1", 10, 50);
    }
    public void room5(Graphics canvas)
    {
        canvas.setColor(Color.WHITE);
        canvas.drawString("You are in the first security room.", 10, 10);
        canvas.drawString("Left: To the Guard Post", 10, 30);
        canvas.drawString("Down: To Cell Block C", 10, 50);
    }
    public void room6(Graphics canvas)
    {
        canvas.setColor(Color.WHITE);
        canvas.drawString("You are in the Guard Post.", 10, 10);
        canvas.drawString("Right: To Security Room 1", 10, 30);
        canvas.drawString("Left: To The Courtyard", 10, 50);
        canvas.drawString("Up: To Solitary Confinement", 10, 70);
    }
    public void room7(Graphics canvas)
    {
        canvas.setColor(Color.WHITE);
        canvas.drawString("You are in the Courtyard.", 10, 10);
        canvas.drawString("Up: To the Guard Post", 10, 30);
        canvas.drawString("Down: To Security Room 2", 10, 50);
    }
    public void SolCon(Graphics canvas)
    {
        canvas.setColor(Color.WHITE);
        canvas.drawString("You are in Solitary Confinement.", 10, 10);
        canvas.drawString("Down: To the Guard Post", 10, 30);
    }
    public void room8(Graphics canvas)
    {
        canvas.setColor(Color.WHITE);
        canvas.drawString("You are in the second security room.", 10, 10);
        canvas.drawString("Right: Leave", 10, 30);
        canvas.drawString("Up: To The Couryard", 10, 50);
    }
    public void room9(Graphics canvas)
    {
        canvas.setColor(Color.WHITE);
        canvas.drawString("You walk by a blown up tank... weird.", 10, 10);
        canvas.drawString("Right: Freedom!", 10, 30);
    }
    public void room10(Graphics canvas)
    {
        canvas.setColor(Color.WHITE);
        canvas.drawString("You are FREE!!.", 10, 10);

    }
    public void room11(Graphics canvas)
    {
        canvas.setColor(Color.WHITE);
        canvas.drawString("You are in SOLITARY CONFINEMENT: HOME OF THE FREAKS!!.", 10, 10);
        canvas.drawString("Down: To the Guard Post.", 10, 30);
    }
    public void guardFight1(Graphics canvas)
    {
        int GuardHP=75,GATK=10;
    }
    public void guardFight2(Graphics canvas)
    {
        int GuardHP=150,GATK=25;
    }
    public void makeMove(Graphics canvas)
    {
        if (curloc==1 &amp;&amp; left)
        {
            curloc=2;
        }
        else if (curloc==1 &amp;&amp; right)
        {
            curloc=3;
        }
        else if (curloc==2 &amp;&amp; right)
        {
            curloc=1;
        }
        else if (curloc==3 &amp;&amp; left)
        {
            curloc=1;
        }
        else if (curloc==3 &amp;&amp; up)
        {
            curloc=4;
        }
        else if (curloc==4 &amp;&amp; down)
        {
            curloc=3;
        }
        else if (curloc==4 &amp;&amp; up)
        {
            curloc=5;
        }
        else if (curloc==5 &amp;&amp; down)
        {
            curloc=4;
        }
        else if (curloc==5 &amp;&amp; left)
        {
            curloc=6;
        }
        else if (curloc==6 &amp;&amp; right)
        {
            curloc=5;
        }
        else if (curloc==6 &amp;&amp; left)
        {
            curloc=7;
        }
        else if (curloc==6 &amp;&amp; up)
        {
            curloc=11;
        }
        else if (curloc==7 &amp;&amp; up)
        {
            curloc=6;
        }
        else if (curloc==7 &amp;&amp; down)
        {
            curloc=8;
        }
        else if (curloc==8 &amp;&amp; up)
        {
            curloc=7;
        }
        else if (curloc==8 &amp;&amp; right)
        {
            curloc=9;
        }
        else if (curloc==9 &amp;&amp; right)
        {
            curloc=10;
        }
        else if (curloc==10)
        {
            //freedom!
        }
        else if (curloc==11 &amp;&amp; down)
        {
            curloc=6;
        }
    }
    public void ran(int randomnumber,int curloc ,Graphics canvas)
    {
        if (curloc==2 &amp;&amp; randomnumber==1)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("You have gained 10 health", 10, 100);
            health=health+10;
        }
        if (curloc==2 &amp;&amp; randomnumber==2)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("None", 10, 100);
        }
        if (curloc==2 &amp;&amp; randomnumber==3)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("None", 10, 100);
        }
        if (curloc==2 &amp;&amp; randomnumber==4)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("None", 10, 100);
        }
        if (curloc==2 &amp;&amp; randomnumber==5)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("You have gained 10 strength", 10, 100);
            strength=strength+10;
        }
        if (curloc==2 &amp;&amp; randomnumber==6)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("None", 10, 100);
        }
        if (curloc==2 &amp;&amp; randomnumber==7)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("None", 10, 100);
        }
        if (curloc==2 &amp;&amp; randomnumber==8)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("None", 10, 100);
        }
        if (curloc==2 &amp;&amp; randomnumber==9)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("None", 10, 100);
        }
        if (curloc==2 &amp;&amp; randomnumber==10)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("You trip and fall and break your ankle", 10, 100);
            canvas.drawString("You lose 5 health",10,120);
            health=health-5;
        }
        //showers
        if (curloc==3 &amp;&amp; randomnumber==1)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("None", 10, 100);
        }
        if (curloc==3 &amp;&amp; randomnumber==2)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("None",10,100);
        }
        if (curloc==3 &amp;&amp; randomnumber==3)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("You find an Energy Drink", 10, 100);
            canvas.drawString("You gain 10 strength",10,120);
            strength=strength+10;
        }
        if (curloc==3 &amp;&amp; randomnumber==4)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("None", 10, 100);
        }
        if (curloc==3 &amp;&amp; randomnumber==5)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("None", 10, 100);
        }
        if (curloc==3 &amp;&amp; randomnumber==6)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("You trip and fall and break your ankle", 10, 100);
            canvas.drawString("You lose 5 health",10,120);
            health=health-5;
        }
        if (curloc==3 &amp;&amp; randomnumber==7)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("You find a First Aid Kit", 10, 100);
            canvas.drawString("You gain 25 health",10,120);
            health=health+25;
        }
        if (curloc==3 &amp;&amp; randomnumber==8)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("You trip and fall and break your ankle", 10, 100);
            canvas.drawString("You lose 5 health",10,120);
            health=health-5;
        }
        if (curloc==3 &amp;&amp; randomnumber==9)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("none", 10, 100);
        }
        if (curloc==3 &amp;&amp; randomnumber==10)
        {
            canvas.drawString("Random Events: ",10,80);
            canvas.drawString("You slip and fall and break your nose", 10, 100);
            canvas.drawString("You lose 5 health",10,120);
            health=health-5;
        }
        if (curloc==10 &amp;&amp; randomnumber==1)
        {
            canvas.drawString("You lunge at the warden. ",10,80);
            canvas.drawString("He dodges and you lose 5 health", 10, 100);
            health=health-5;
        }
        if (curloc==10 &amp;&amp; randomnumber==2)
        {
            canvas.drawString("You lunge at the warden. ",10,80);
            canvas.drawString("He dodges and you lose 5 health", 10, 100);
            health=health-5;
        }
        if (curloc==10 &amp;&amp; randomnumber==3)
        {
            canvas.drawString("You lunge at the warden. ",10,80);
            canvas.drawString("He dodges and you lose 0 health", 10, 100);
        }
        if (curloc==10 &amp;&amp; randomnumber==4)
        {
            canvas.drawString("You lunge at the warden. ",10,80);
            canvas.drawString("He attacks and you lose 5 health", 10, 100);
            health=health-5;
        }
        if (curloc==10 &amp;&amp; randomnumber==5)
        {
            canvas.drawString("You lunge at the warden. ",10,80);
            canvas.drawString("He attacks and you lose 0 health", 10, 100);
        }
        if (curloc==10 &amp;&amp; randomnumber==6)
        {
            canvas.drawString("You lunge at the warden. ",10,80);
            canvas.drawString("He attacks and you lose 5 health", 10, 100);
            health=health-5;
        }
        if (curloc==10 &amp;&amp; randomnumber==7)
        {
            canvas.drawString("You lunge at the warden. ",10,80);
            canvas.drawString("He attacks and you lose 0 health", 10, 100);
        }
        if (curloc==10 &amp;&amp; randomnumber==8)
        {
            canvas.drawString("You lunge at the warden. ",10,80);
            canvas.drawString("He attacks and you lose 5 health", 10, 100);
            health=health-5;
        }
        if (curloc==10 &amp;&amp; randomnumber==9)
        {
            canvas.drawString("You lunge at the warden. ",10,80);
            canvas.drawString("He attacks and you lose 0 health", 10, 100);
        }
        if (curloc==10 &amp;&amp; randomnumber==10)
        {
            canvas.drawString("You lunge at the warden. ",10,80);
            canvas.drawString("He attacks and you lose 5 health", 10, 100);
            health=health-5;
        }


    }
    public void fight (Graphics canvas, int fightcount,int curloc)
    {

        if(curloc==10)
        {
            fightcount=fightcount-1;
        }
        else if (curloc==10 &amp;&amp; fightcount==0)
        {
            JOptionPane.showMessageDialog(null, "You Win!");
        }
    }
    {

    }
    public void dispLoc(Graphics canvas)
    {
        if (curloc==1)
        {
            room1(canvas);
            //cell
        }
        if (curloc==2)
        {
            room2(canvas);
            //training
        }
        if (curloc==3)
        {
            room3(canvas);
            //showers
        }
        if (curloc==4)
        {
            room4(canvas);
            //Cell Block C
        }
        if (curloc==5)
        {
            room5(canvas);
            //Security Room1
        }
        if (curloc==6)
        {
            room6(canvas);
            //Guard Post
        }
        if (curloc==7)
        {
            room7(canvas);
            //Courtyard
        }
        if (curloc==8)
        {
            room8(canvas);
            //Security Room 2
        }
        if (curloc==9)
        {
            room9(canvas);
            //Tank
        }
        if (curloc==10)
        {
            room10(canvas);
            //Freedom
        }
        if (curloc==11)
        {
            room11(canvas);
            //Solitary Confinement
        }
    }
    public void stats(Graphics canvas)
    {
        canvas.drawString("Health: " + health, 750, 10);
        canvas.drawString("Strength: " + strength, 750, 30);
    }
    public void health(Graphics canvas, int health)
    {
        if (health==0)
        {
            JOptionPane.showMessageDialog(null,"You Died Game over!");
            System.exit(0);
        }
    }
     public void delayGame(double numSecs)
     {
        double delayTime = 1000 * numSecs;
        long startDelay = System.currentTimeMillis();
        long endDelay = 0;

        while (endDelay - startDelay &lt; delayTime)
        {
          endDelay = System.currentTimeMillis();
        }
     }
     public int randomnum()
     {
         int n1=0;
         n1=(int) (Math.random()*10+1);
         return n1;
     }
     public void clearScreen(Graphics g)
     {
        g.setColor(Color.BLACK);
        g.fillRect(0,0,5000,5000);
     }
     public void keyPressed(KeyEvent e)
     {
      int key = e.getKeyCode();


      if (key == KeyEvent.VK_LEFT)
      {
        left = true;
        repaint();
      }

      if (key == KeyEvent.VK_DOWN)
      {
        down = true;
        repaint();
      }

      if (key == KeyEvent.VK_RIGHT)
      {
        right = true;
        repaint();
      }

      if (key == KeyEvent.VK_UP)
      {
        up = true;
        repaint();
      }

      if (key == KeyEvent.VK_SPACE)
      {
        space = true;
        repaint();
      }

      if (key == KeyEvent.VK_ENTER)
      {
        enter = true;
        repaint();
      }

     }
     public void focusGained(FocusEvent evt) {focus=true; repaint();}
     public void focusLost(FocusEvent evt) {focus=false;}
     public void keyReleased(KeyEvent e){}
     public void keyTyped(KeyEvent e) {}
     public void restart(Graphics g){}

}
</code></pre>
