为什么我的if语句输出不正确?

时间:2019-11-29 03:18:05

标签: java

这是我的代码:

public static void showScore()
            {
               int score = calculateMaxScore();
               String comment = "";
               if(score > -1  && score < 4);
               {
                 comment = "Get Good!";
               }

               if(score > 2 && score <7);
               {
                 comment = "Good!";
               }

               if(score > 6 && score < 10);
               {
                 comment = "Excellent!";
               }
               String message = ("You scored " + score + "! " + comment);
               GWorld.removeObjectsFromWorld(GWorld.getAllObjects("Message"));
               Message m = new Message(message);
               GWorld.addOneObject(m, WORLD_WIDTH-2, 0);    

            }

calculateMaxScore()只是将用户在游戏中获得的分数放入可变分数中。我正在使用下面的3个if语句创建注释,该注释将在message变量中输出。由于某种原因,无论score中的值是多少,唯一使用的注释就是“ Excellent!”。例如:如果我的分数是1,则消息应该是“您得分1”!变得好!,而是您获得了1分!很棒!

这是为什么,有人可以帮助我修复它吗?

谢谢。

0 个答案:

没有答案