newbie here,
I have two variables which generate random numbers through .Random
. I want them keep rolling until both variables generate two different values, si
You're getting the logical result you describe, but it wasn't what you expect. Specifically, when either of your conditions evaluates to false
the logical and will not evaluate to true
. I think you wanted
while (!(diceRolled1 == 5 && diceRolled2 == 4)) {
which is while
not dice1 equal to 5 and dice2 equal to 4. And then, using De Morgan's Laws that might also be expressed as
while (diceRolled1 != 5 || diceRolled2 != 4) {
which means loop while
dice1 is not equal to 5 or dice2 is not equal to 4.