title: TicTacToe Problems
body: <p>I am stuck on my tictactoe problem. Define a calss called TicTacToe. An object of type TicTacToe is a single game of TicTacToe. Store the game board as a single 2d array of base type char that has three rows and three columns. Include methods to add a move, display the board, to tell whose turn it is, to tell whether there is a winnner, to say who the winner is, and to restart the game to the beginning. Write a main method for the class that will allow two players to enter their moves in turn at the same keyboard.</p>
  
  <p>I have some of my methods written and have been testing as I go. When I test my code I either get it to place a mark but also print out invalid entry or it will continuously loop through asking for a move and then saying the space is occupied. I can't figure out how to fix that. I'm sure it has something to do with my do while loop and the boolean methods for isEmpty and notValid. Also I'm stuck on how to implement a counter for each player's win. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>    public void addMove()
      {
          checkTurn();
          int row, col;
          do
          {
          System.out.println("Enter a row (1-3): ");
          row = in.nextInt() - 1; //Array index starts at 0.
          System.out.println("Enter a column (1-3): ");
          col = in.nextInt() - 1;
  
          if (row&gt;=0 &amp;&amp; row&lt;ROWS)
              if(col&gt;=0 &amp;&amp; col&lt;COLUMNS)
                  if (playerX)
                      {
                          gameBoard[row][col] = player1Move;
                      }
                      else 
                      {
                          gameBoard[row][col] = player2Move;
                      }
           checkForWin();
           changePlayer();
          }while (notValid(row,col));
  
              System.out.println("Invaild Entry.");
              //System.exit(0); 
  
          //checkForWin();
          //changePlayer();
      }
      public boolean notValid(int row, int col)
      {
          if (row &lt; 0 || row &gt; ROWS )
              return true;
          if (col &lt; 0 || col &gt; COLUMNS)
              return true;
          if (!isEmpty(row,col))
              return true;
          return false;
      }
      public boolean isEmpty(int row, int col)
      {
          if(gameBoard[row][col]==' ')
              return true;
          else
          {
              System.out.println("Space is already occupied.");
              return false;
          }
      }
  }   
  </code></pre>
  
  <p>Here is my testing class:</p>
  
  <pre><code>public class TicTacToe
  {
  
      public static void main(String[] args) 
      {
      TicTacToeClass game = new TicTacToeClass();
      game.addMove();
      game.printBoard();
  
  
      }
  
  }
  </code></pre>