March 2018
Intermediate to advanced
324 pages
8h 30m
English
This requirement introduces part of the logic of the game.
In this part, board bounds become relevant. We need to mark what positions are already taken, using Color.RED to indicate them. Finally, the first private method is created. It is a helper method that calculates the number of discs introduced in a given column:
public void putDisc(int column) { if (column > 0 && column <= COLUMNS) { int numOfDiscs = getNumberOfDiscsInColumn(column - 1); if (numOfDiscs < ROWS) { board[column - 1][numOfDiscs] = Color.RED; } ...Read now
Unlock full access