1 2
|
for(int i = 0; i<= 3; i++)
for(int j = 0; j <= 3; j++)
|
Should be:
1 2 3 4 5
|
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) {
// do something
}
}
|
It's a good idea to always use the braces, even though there is 1 statement following. It will save you one day when you add more code.
gameBoard[3][3]
is out of bounds for the array. Valid subscripts are 0, 1, 2 .
The body of the for loop is not evaluated when the end condition becomes false, so it stops at 2.
I would change the other ones that look like this
for(int row = 0; row <= 2; row++)
.
I haven't looked any further for other errors.
The way to find out about runtime errors is to use the debugger - should be easy if you are using an IDE, a little bit more tricky from the command line but not impossible. You can have a watch list of variables, see how they change as you step through the code 1 line at a time, see where they go wrong & deduce the problem.
I find function names, that are too general as well as being the same across different classes, a bit confusing . You have setValue in the player class & the tictactoe class, can you rename them to something more meaningful?
HTH