title: Subtract-a-Square game in Java
body: <p>The assignment is writing the two-player game Subtract-a-Square using Java. The players make turns subtracting a square number and a player emerges victirous if he makes the final move. We are supposed to implement the function <strong>boolean isSquare(int a)</strong> to check if the number entered is a square and the user input is legal. I've done the boolean to check if it's a square, but I fail to find a way to make the two players make alternating turns. Thank you!</p>
  
  <pre><code>public class Squares {
    public static void main(String[] args) { 
  
      int sum = (int)(Math.random()*11)+10;
  
      while(!StdIn.isEmpty()) {
        int i = 1;
        if (i % 2 == 0) {
          int P1 = Integer.parseInt(args[0]);
          sum = sum - P1;
        }
        else {
          int P2 = Integer.parseInt(args[1]);
          sum = sum - P2;
        }
        i++;
      }
    }
  
    public static boolean isSquare(int a) {
      for (int i = 0; i &lt; 20; i++) {
       //   sum = sum - player input 
      }
  
      if (a &lt; 0 || a &gt; sum)
        System.out.println("Wrong input: ");
      for (int i = 0; i &lt; a / 2 + 2; i++) {
          if (i * i == a)
              return true;
      }
      return false;
    }
  
  }
  </code></pre>