The way we're handling possible diagonal wins, the calculation doesn't look right. Maybe the reutilization of the existing loop would make more sense:
private boolean isWin() { int playerTotal = lastPlayer * 3; char diagonal1 = ' '; char diagonal2 = ' '; for (int i = 0; i < SIZE; i++) { diagonal1 += board[i][i]; diagonal2 += board[i][SIZE - i - 1]; if (board[0][i] + board[1][i] + board[2][i]) == playerTotal) { return true; } else if (board[i][0] + board[i][1] + board[i][2] == playerTotal) { return true; } } if (diagonal1 == playerTotal || diagonal2 == playerTotal) { return true; } return false; }
The source code can be found in the 03-wins branch of the tdd-java-ch03-tic-tac-toe Git repository at https://bitbucket.org/vfarcic/tdd-java-ch03-tic-tac-toe/branch/03-wins.
Now, let's go through the last requirement.