Java: Do-while loop with multiple conditions
<p>I am trying to create the scissors-paper-stone-game in Java with a do-while loop. The computer will randomly select 1, and the user makes his choice. The exit condition is if the user wins twice (<code>userWin</code>) or the computer wins twice (<code>compWin</code>). If there is a draw, neither counter increases.</p>

<pre><code>// Scissors, paper, stone game. Best of 3.
// scissors = 0; paper = 1; stone = 2;
import java.util.Scanner;
public class Optional2 {

    public static void main(String[] args) {

            int userWin = 0;
            int compWin = 0;

            do {
                //comp choice
                int comp = 1;       //TEST CASE
            //  int comp = (int) (Math.random() * (2 - 0 + 1) + 0);

                //user choice
                System.out.println("0 for scissors, 1 for paper, 2 for stone");
                Scanner sc = new Scanner(System.in);
                int user = sc.nextInt();

                    //Draw
                    if (comp == user) {
                        System.out.println("Draw");
                    //Win =)
                    } else if (comp == 0 &amp;&amp; user == 2 || comp == 1 &amp;&amp; user == 0 || 
                                comp == 2 &amp;&amp; user == 1) {
                        System.out.println("WIN!");
                        userWin++;
                    //Lose =(
                    } else {
                        System.out.println("Lose =(");
                        compWin++;
                    }
            } while (compWin &lt; 2 || userWin &lt; 2);

            System.out.println("You won " + userWin + " times!");   
    }
}
</code></pre>

<p>For <code>int comp</code>, it should be random, but I am setting it to 1 (paper) for easy testing.</p>

<p>However, presently only the 1st condition will exit the loop if it becomes true. I am expecting the 2nd condition to exit the loop too if it becomes true with the <code>||</code> operator, but the loop just keeps looping even if it comes true.</p>

<p>ie. if I put <code>while (userWin &lt; 2 || compWin &lt; 2)</code>, it will exit if the user wins twice but not if the computer wins twice. If I put while (compWin &lt; 2 || userWin &lt; 2), it will exit if the computer wins twice but not if the user wins twice.</p>

<p>I tried changing it to <code>while ((userWin &lt; 2) || (compWin &lt; 2))</code> too but it doesn't work.</p>