Requirement 5 – win condition (I)

This requirement tells the system whether the game is finished.

When no more discs can be inserted, the game finishes and it is considered a draw.

There are two conditions to test. The first condition is that new game must be unfinished; the second condition is that full board games must be finished:

@Test
public void whenTheGameStartsItIsNotFinished() {
  assertFalse("The game must not be finished", tested.isFinished()); 
} 
 
@Test 
public void whenNoDiscCanBeIntroducedTheGamesIsFinished() { 
  for (int row = 0; row < 6; row++)
    for (int column = 0; column < 7; column++)
      tested.putDiscInColumn(column);
    assertTrue("The game must be finished", tested.isFinished()); 
}

An easy and simple solution to these two tests is as follows:

public boolean isFinished() {
  return getNumberOfDiscs() == ROWS * COLUMNS;
}
..................Content has been hidden....................

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