MineSweeper { boolean minesweeper1(int[][] gameboard) { int r = gameboard.length; int c = r == 0 ? 0 : gameboard[0].length; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { int v = gameboard[i][j]; if (v != 9) { int b = 0; for (int[] neigh: NEIGHBORS) { int ni = i + neigh[0]; int nj = j + neigh[1]; if (ni >= 0 && ni < r && nj >= 0 && nj < c && gameboard[ni][nj] == 9) { b++; } } if (b != v) { return false; } } } } return true; }    }
@Test(dataProvider = "mine1") public void testSweeper1(int[][] matrix, boolean expected) { assertEquals(new MineSweeper().minesweeper1(matrix), expected); }