日期:2014-05-20  浏览次数:20746 次

我是java新手,老师叫我写猜拳游戏,然后出了点问题!
public static void main(String[] agrs){

// Game game = new Game();
// game.startGame();
Person p = new Person();
Computer c = new Computer();
p.showFist();
c.showFist();
// System.out.println(p.n);
// System.out.println(c.a);
if(p.n == c.a)
{
System.out.println("平");
}
else if(p.n - c.a == 1 && p.n - c.a == -2)
{
System.out.println("lost");
// System.out.println(p.n);
// System.out.println(c.a);
}
else
{
System.out.println("win");
}

结果没有执行else if里的判断,无论是lost还是win,一直都是在执行else里的win,这是怎么回事,就大神帮忙。
------解决方案--------------------
else if(p.n - c.a == 1 && p.n - c.a == -2)
这永远不会成立吧