1.1 --- a/src/main/java/de/uapcore/sudoku/Field.java Sat Jul 25 15:56:48 2020 +0200 1.2 +++ b/src/main/java/de/uapcore/sudoku/Field.java Mon Jul 27 10:56:17 2020 +0200 1.3 @@ -36,7 +36,7 @@ 1.4 * Cells are identified by zero-based indices from top-left to bottom-right. 1.5 */ 1.6 public final class Field extends JPanel { 1.7 - private SudokuTextField[][] cells; 1.8 + private final SudokuTextField[][] cells; 1.9 1.10 /** 1.11 * Constructs a new 9x9 Sudoku grid. 1.12 @@ -124,6 +124,7 @@ 1.13 * @param x horizontal position 1.14 * @param y vertical position 1.15 * @param v the cells value 1.16 + * @throws IllegalArgumentException if v is not between 0 and 9 1.17 */ 1.18 public void setCellValue(int x, int y, int v) { 1.19 cells[x][y].setValue(v); 1.20 @@ -198,6 +199,7 @@ 1.21 * @param x horizontal position from 0 to 2 1.22 * @param y vertical position from 0 to 2 1.23 * @return a two-dimensional array containing the square cell values 1.24 + * @throws IllegalArgumentException if the coordinates are out of bounds 1.25 */ 1.26 public int[][] getSquare(int x, int y) { 1.27 if (x < 0 || x > 2 || y < 0 || y > 2) { 1.28 @@ -219,12 +221,13 @@ 1.29 * 1.30 * @param y the row position 1.31 * @return an array containing the row values 1.32 + * @throws IllegalArgumentException if y is not between 0 and 8 1.33 */ 1.34 public int[] getRow(int y) { 1.35 if (y < 0 || y > 8) { 1.36 throw new IllegalArgumentException("Invalid row number"); 1.37 } 1.38 - int row[] = new int[9]; 1.39 + int[] row = new int[9]; 1.40 1.41 for (int x = 0; x < 9; x++) { 1.42 row[x] = getCellValue(x, y); 1.43 @@ -238,12 +241,13 @@ 1.44 * 1.45 * @param x the column position 1.46 * @return an array containing the column values 1.47 + * @throws IllegalArgumentException if x is not between 0 and 8 1.48 */ 1.49 public int[] getColumn(int x) { 1.50 if (x < 0 || x > 8) { 1.51 throw new IllegalArgumentException("Invalid column number"); 1.52 } 1.53 - int column[] = new int[9]; 1.54 + int[] column = new int[9]; 1.55 1.56 for (int y = 0; y < 9; y++) { 1.57 column[y] = getCellValue(x, y);