### Question:
MaxScores extends Scores { @Override protected void snakeEatApple() { length++; int current = 0; for (int i = setup.startSnakeLength().getValue() + 1; i <= length; i++) { current += i; } score = Math.max(score, current); } MaxScores(int startScore, SnakeSettings setup);   }### Answer:
@Test public void shouldCollectScores() { scores = getScores(scoreFor(7), 7); snakeEatApple(); assertEquals(8, length()); assertEquals(scoreFor(8), score()); snakeEatApple(); assertEquals(9, length()); assertEquals(scoreFor(9), score()); snakeEatApple(); assertEquals(10, length()); assertEquals(scoreFor(10), score()); snakeEatApple(); assertEquals(11, length()); assertEquals(scoreFor(11), score()); snakeEatApple(); assertEquals(12, length()); assertEquals(scoreFor(12), score()); snakeEatApple(); assertEquals(13, length()); assertEquals(scoreFor(13), score()); }
@Test public void shouldClearScoreTogetherWithSnakeLength() { scores = getScores(0); snakeEatApple(); snakeEatApple(); snakeEatApple(); snakeEatApple(); snakeEatApple(); snakeEatApple(); snakeEatApple(); snakeEatApple(); snakeEatApple(); snakeEatApple(); scores.clear(); assertEquals(0, score()); assertEquals(2, length()); snakeEatApple(); snakeEatApple(); assertEquals(scoreFor(4), score()); assertEquals(4, length()); }
@Test public void shouldClearScore() { scores = getScores(0); snakeEatApple(); scores.clear(); assertEquals(0, score()); }