March 2018
Intermediate to advanced
324 pages
8h 30m
English
The first game has a finished condition.
The following code shows one of the possible implementations:
...
public boolean isFinished() {
int numOfDiscs = 0;
for (int col = 0; col < COLUMNS; ++col) {
numOfDiscs += getNumberOfDiscsInColumn(col);
}
if (numOfDiscs >= COLUMNS * ROWS) {
System.out.println("It's a draw");
return true;
}
return false;
}
...
Read now
Unlock full access