Requirement 1 – the game's board

Let us start with the first requirement.


The board is composed of seven horizontal and six vertical empty positions.

The implementation of this requirement is pretty straightforward. We just need the representation of an empty position and the data structure to hold the game. Note that the colors used by the players are also defined:

public class Connect4 {
  public enum Color {
    RED('R'), GREEN('G'), EMPTY(' ');
 
private final char value;
Color(char value) { this.value = value; }
@Override public String toString() { return String.valueOf(value); } } public static final int COLUMNS = 7; public static final int ROWS = 6; private Color[][] board = new Color[COLUMNS][ROWS]; public Connect4() { for (Color[] column : board) { Arrays.fill(column, Color.EMPTY); } } }
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.147.77