Java If-else语句在第二次调用期间跳过

Java If-else语句在第二次调用期间跳过,java,eclipse,if-statement,Java,Eclipse,If Statement,这是while循环,它多次调用方法x while (count<=rounds){ System.out.println("Round " + round); PlayerVsPlayer.results(); count++; round++; } 这是compare.winScore(Player1,Player2)中if-else语句的一个片段: 我遇到的问题是,第一次执行if-else语句时,它工作得非常好。第二次,if-e

这是while循环,它多次调用方法x

while (count<=rounds){
    System.out.println("Round " + round);
    PlayerVsPlayer.results();
    count++;
    round++;            
}
这是compare.winScore(Player1,Player2)中if-else语句的一个片段:


我遇到的问题是,第一次执行if-else语句时,它工作得非常好。第二次,if-else语句跳过并返回第一次调用的值。有人知道为什么会这样吗?谢谢你的帮助

我重写了这个winScore方法来检查“其他”情况


您是使用相同的值调用还是使用不同的值调用?什么值?错误出现在代码中而不是Java中的概率约为99.9997比1。尝试在
winScore()
的条目上打印x和y。您要求用户选择R、P和S。然后与岩石和纸张进行比较。此外,它不限制用户输入任何他们想要的内容。
        Scanner scan = new Scanner(System.in);
        System.out.print("Choose (R)ock, (P)aper, or (S)cissors:");
        String Player1 = scan.nextLine();
        System.out.print("Choose (R)ock, (P)aper, or (S)cissors:");
        String Player2= scan.nextLine();
        String[] Results = compare.winScore(Player1, Player2);
static String[] winScore(String x, String y){

    if (x.equals(y)) {
        winnerScoreRule.add("Round results is a tie, no one wins.");
        winnerScoreRule.add("");
        winnerScoreRule.add("");
    }
    else if ((x.equals("Rock")) && (y.equals("Paper"))){
        score2++; count++;
        winnerScoreRule.add("Player 2 wins this round!");
        winnerScoreRule.add("The score is " + score1 +" to "+ score2);
        winnerScoreRule.add("Paper beats rock!"); // etc.
    }
static String[] winScore(String x, String y){

        if (x.equals(y)) {
            winnerScoreRule.add("Round results is a tie, no one wins.");
            winnerScoreRule.add("");
            winnerScoreRule.add("");
        }
    //you're asking them to enter (R), (P) or (S)
        else if ((x.toLowerCase().equals("r")) && (y.toLowerCase().equals("p"))){
            score2++; count++;
            winnerScoreRule.add("Player 2 wins this round!");
            winnerScoreRule.add("The score is " + score1 +" to "+ score2);
            winnerScoreRule.add("Paper beats rock!"); // etc.
        }
       ....//other logic for Rock Paper Scissors
        else
       {
           throw WrongOptionSelectedException(); //custom exception for wrong entry
        }