Requirement 3 – adding winning conditions

It's time to work on winning according to the rules of the game. This is the part where, when compared with the previous code, work becomes a bit more tedious. We should check all the possible winning combinations and, if one of them is fulfilled, declare a winner.

A player wins by being the first to connect a line of friendly pieces from one side or corner of the board to the other.

To check whether a line of friendly pieces is connected, we should verify horizontal, vertical, and diagonal lines.

Get Test-Driven Java Development - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.