Tic-Tac-Toe
Iteration with 2D Arrays
Hacks:
- This program is more Object-Oriented because each Tic-Tac-Toe board and player is an object. Almost every function is non-static
- In each class all variables are declared locally and are initialized inside the constructor
- Inside the class
TicTacToeBoard
, the constructor initializes the double arrayboard
.
board = new String [NUM_ROWS][NUM_COLUMNS];
for (int row = 0; row < NUM_ROWS; row++)
{
for (int column = 0; column < NUM_COLUMNS; column++)
{
board[row][column] = new String(" ");
}
}