I feel like the problem is that I do not reset the array before each case, but I am not sure how to do that.
Printable View
I feel like the problem is that I do not reset the array before each case, but I am not sure how to do that.
Something like this may do the trick:
Code:public void resetBoard()
{
for(int i = 0; i < rows; i++)
for(int j = 0; j < columns; i++)
board[rows][column] = null;
}
You bypass each of the case statements when direction==0
But you were getting the exception at LegalMove() case 5 (assuming that's line 75). So EITHER putting
Code:System.out.println("row="+row+"column="+column);
at the start of that case block will print some useful diagnostic information OR you don't get the exception.