I am working on an assignment to create a tictactoe game using a multidimensional array, a separate class with methods to be invoked by the main class.
The array is 3 X 3 and is initialized to zero. When player 1 chooses a location on the board a 1 is put in that specific index. Then the prompt allows player 2 to make their selection. Each time a player takes their turn a method is invoked to check if the board is complete, if it is complete (filled with 1's and 2') then the game is called a draw. This method is not working as it should and it calls the game a draw sometimes on the second move. Here is my method i am using.
public boolean isBoardComplete()
{
// sets complete to true
boolean complete = true;
//will change complete to false
for (int i = 0; i < 3; i++)
{
for(int j =0; j < 3; j++)
{
if (_board[i][j] == 0)
{
complete = false;
}
}
}
return complete;
}