public class TicTacToe {
  
  // This is a constant.
  // Constant names are all uppercase.
  // Constants cannot be reassigned once
  // they have been initialized.
  private static final int BOARD_SIZE = 3;
 
  /** An empty square on the board. */
  private static final char BLANK_SQUARE = ' ';
  
  /** The letter representing player one. */
  private static final char PLAYER_ONE = 'X';
  
  /** The letter representing player two. */
  private static final char PLAYER_TWO = 'O';
  
  /** The tic-tac-toe board. */
  private char [] [] board;
  
  
  /** 
   * Create a new tic tac toe board. 
   */
  public TicTacToe() {
    board = new char[BOARD_SIZE] [BOARD_SIZE];
    for (int i = 0; i < BOARD_SIZE; i++) {
      for (int j = 0; j < BOARD_SIZE; j++) {
        board[i][j] = BLANK_SQUARE;
      }  
    }
  }
  
  /**
   * Set a mark on the board.
   */
  public void setMark(int row, int col, char mark) {
    board [row] [col] = mark;
  }
  
  /** 
   * Displaying the board.
   * We want the board to look like a reall tic-tac-toe cross-hatch
   * As we add values, they will fill in the spaces:
   * | | 
   *_ _ _
   * | |
   *_ _ _
   * | | 
   */
  public String toString() {
    String result = "";
    for (int i = 0; i < BOARD_SIZE; i++) {
       result+= board[i][0];
       for (int j = 1; j < BOARD_SIZE; j++) {
         result += "|" + board[i][j];
       }
       result += "\n";
       if (i <  BOARD_SIZE - 1) {
         result += "_ _ _\n";
       }
    }
    return result;
  }
                                 
}   

  
