mercredi 2 décembre 2015

Strange if statement always running even if conditions are not met [on hold]

I have a strange problem with an if statement. I'm checking if a Boolean is true, if it is the if statement must run. I System.out.println the value of the boolean at a lot of places, its always false but the if statement still runs. Any help ?

    import java.util.ArrayList;

public class GameLoop extends Thread {
private Boolean running;
private ArrayList<Meteor> meteorArrayList;
private Boolean win;
private GameScreen gameScreen;

public GameLoop(GameScreen gameScreen, ArrayList<Meteor> meteorArrayList)
{
    setMeteorArrayList(meteorArrayList);
    setGameScreen(gameScreen);
    setRunning(true);
    setWin(false);
}

@Override
public void run()
{
    while (running)
    {
        if(checkWin());
        {
            System.out.println(checkWin());
            gameScreen.winGame();
        }
    }
}

public Boolean checkWin()
{
    if(getMeteorArrayList().isEmpty())
    {
        setWin(true);
    }
    else
    {
        setWin(false);
    }
    System.out.println(getWin());
    return getWin();
}

public void cancel()
{
    interrupt();
}

//======================GETTER EN SETTERS=============================


public Boolean getRunning() {
    return running;
}

public void setRunning(Boolean running) {
    this.running = running;
}

public ArrayList<Meteor> getMeteorArrayList() {
    return meteorArrayList;
}

public void setMeteorArrayList(ArrayList<Meteor> meteorArrayList) {
    this.meteorArrayList = meteorArrayList;
}

public Boolean getWin() {
    return win;
}

public void setWin(Boolean win) {
    this.win = win;
}

public GameScreen getGameScreen() {
    return gameScreen;
}

public void setGameScreen(GameScreen gameScreen) {
    this.gameScreen = gameScreen;
}

}

Aucun commentaire:

Enregistrer un commentaire