Page 402 - AP Computer Science A, 7th edition
P. 402
public class TicTacToe {
private String[][] board;
private static final int ROWS = 3; private static final int COLS = 3;
/∗ ∗ Construct an empty board. ∗ / public TicTacToe()
{
board = new String[ROWS][COLS]; for (int r = 0; r < ROWS; r++)
for (int c = 0; c < COLS; c++) board[r][c] = “ ”;
}
/∗ ∗ ∗ ∗
@param r the row number
@param c the column number
@param symbol the symbol to be placed on
board[r][c]
∗ Precondition: The square board[r][c] is empty.
∗ Postcondition: symbol placed in that square.
∗/
public void makeMove(int r, int c, String symbol)
{
board[r][c] = symbol; }
/∗∗ Creates a string representation of the board, e.g.
∗ |o|
∗ |xx |
∗ |o|
∗ @return the string representation of board ∗/
public String toString() {
String s = “ ”; /∗ more code ∗ / return s;
} }
//empty string