help manipulating a 3D array
<p>This game is a 3D version of tic-tac-toe with 3 boards. Each position on the boards are made up of [x,y,z] coordinates. x is the number of the board and y,z are the coordinates on that board. I'm trying to define a method that only lets you choose from the first board for the first 9 turns of the game, but am having problems. Here is the code. </p>

<pre><code>public void set(Position p, int v) throws IOException { 
  if (board[p.x][p.y][p.z]!= 0) throw new IOException("Position taken");
  board[p.x][p.y][p.z] = v;
</code></pre>

<p>I'm not sure what to add to this method to only allow moves on board one for the first 9 turns. I have tried using a counter such as an if statement such as...</p>

<pre><code>public void set(Position p, int v) throws IOException { 
                int counter = 0;
  if (board[p.x][p.y][p.z]!= 0) throw new IOException("Position taken");
  board[p.x][p.y][p.z] = v;
                  while (counter &lt; 10) {
                  if (p.x != 1) throw new IOException("Invalid Move");
                  }
</code></pre>

<p>When I tried this and other manipulated versions of this same method I kept getting the "Invalid Move" error everytime, even when p.x was equal to 1. Any suggestions on how to loop this or any other ways to accomplish this? </p>
