ExcludeNeighborsBoardMiner implements IBoardMiner { @Override public void mine(final IBoard board, final int bombs, final IField excludeField) { Point dimension = board.getDimension(); List<Field> excludeList = createExcludeList((Field) excludeField); if (bombs >= dimension.x * dimension.y - excludeList.size()) setAllOthersBombs(board, excludeList, dimension); else setBombsRandomly(board, bombs, excludeList, dimension); }  @Override void mine(final IBoard board, final int bombs, final IField excludeField);  }
@Test public void testMine() { Board board = new Board(5, 5); int bombs = 10; new ExcludeNeighborsBoardMiner().mine(board, bombs, (Field) board.getField(1, 1)); assertEquals(bombs, countBombs(board)); assertEquals(false, board.getField(1, 1).isBomb()); }
@Test public void testTooManyBombs() { Board board = new Board(5, 5); int bombs = 25; new ExcludeNeighborsBoardMiner().mine(board, bombs, (Field) board.getField(1, 1)); assertEquals(16, countBombs(board)); assertEquals(false, board.getField(1, 1).isBomb()); }