mardi 19 octobre 2021

Why is my java code not capturing my response except once, even though it is a while loop? [closed]

So within my code i have a bunch of if and while loops. Interestingly enough if i run the code once and answer no it moves on and does what it is supposed to do. If i answer yes and then no the loop keeps on repeating and it keeps asking me if i want to play?

   boolean check = checkAllPlayersHavePassed();
   boolean checkHumanAnswer = human.getPass();
   while (check != true) {
       controlPlay(scanner);
       check = checkAllPlayersHavePassed();
       if (check == true && checkHumanAnswer == false) {
           printResults();
           printWinner();
        
       }
   }

so basically the game has a rule where if the human passes they shouldn't get the option to play again (when they answer no) the computer keep on playing until they pass (get a number that is equal or bigger than 21) The code now only recognizes when the human passes the first time they get asked but not after that. So if i answer yes and then no it doesn't capture me passing

Aucun commentaire:

Enregistrer un commentaire