March 2018
Intermediate to advanced
324 pages
8h 30m
English
This is the same win condition, but in a different direction.
A few lines to implement this rule are as follows:
...
private void checkWinCondition(int col, int row) {
...
// Horizontal check
stringJoiner = new StringJoiner("");
for (int column = 0; column < COLUMNS; ++column) {
stringJoiner.add(board[column][row].toString());
}
if (winPattern.matcher(stringJoiner.toString()).matches()) {
winner = currentPlayer;
System.out.println(currentPlayer + " wins");
return;
}
...
}
...
Read now
Unlock full access