Requirements

To code the two implementations of Connect 4, the game rules are transcribed as follows in the form of requirements. These requirements are the starting point for both the developments. We will go through the code with some explanations and compare both implementations at the end:

  1. The board is composed of seven columns and six rows; all positions are empty.
  2. Players introduce discs on the top of the columns. The introduced disc drops down the board if the column is empty. Future discs introduced in the same column will stack over the previous ones.
  3. It is a two-person game, so there is one color for each player. One player uses red (R) and the other one uses green (G). Players alternate turns, inserting one disc every time.

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.