-2

我只是不明白为什么这个循环只运行一次,但它让我发疯。提前感谢您的帮助。

public class Test
{

public static void main (String [] args)
{
    gladiator fighterA = new gladiator("Maximus", 25, 5, 10, 11, 8, 2, 1, true);
    gladiator fighterB = new gladiator("Minimus", 22, 8, 12, 10, 8, 4, 1, true);

    while(fighterA.getAlive() == true && fighterB.getAlive() == true);
    {
        double userDmg = (fighterA.getAttack() - fighterB.getDefence())*fighterA.getModifier();
        double enemyDmg = (fighterB.getAttack() - fighterA.getDefence())*fighterB.getModifier();
        //System.out.println(userDmg);
        //System.out.println(enemyDmg);
        fighterA.setHp(fighterA.getHp() - enemyDmg);
        fighterB.setHp(fighterB.getHp() - userDmg);
        //System.out.println(fighterA.getHp());
        //System.out.println(fighterB.getHp());
        if(fighterA.getHp() <= 0)
        {
            fighterA.setAlive(false);
        }
        if(fighterB.getHp() <= 0)
        {
            fighterB.setAlive(false);
        }
    }

    System.out.println("The fight is over!");

}

}

4

1 回答 1

1

使用 Eclipse 的调试功能:http ://www.ibm.com/developerworks/library/os-ecbug/

嗯嗯,断点。

于 2013-01-13T02:22:44.103 回答