--- a/src/main/java/de/uapcore/sudoku/Field.java Sat Jul 25 15:56:48 2020 +0200 +++ b/src/main/java/de/uapcore/sudoku/Field.java Mon Jul 27 10:56:17 2020 +0200 @@ -36,7 +36,7 @@ * Cells are identified by zero-based indices from top-left to bottom-right. */ public final class Field extends JPanel { - private SudokuTextField[][] cells; + private final SudokuTextField[][] cells; /** * Constructs a new 9x9 Sudoku grid. @@ -124,6 +124,7 @@ * @param x horizontal position * @param y vertical position * @param v the cells value + * @throws IllegalArgumentException if v is not between 0 and 9 */ public void setCellValue(int x, int y, int v) { cells[x][y].setValue(v); @@ -198,6 +199,7 @@ * @param x horizontal position from 0 to 2 * @param y vertical position from 0 to 2 * @return a two-dimensional array containing the square cell values + * @throws IllegalArgumentException if the coordinates are out of bounds */ public int[][] getSquare(int x, int y) { if (x < 0 || x > 2 || y < 0 || y > 2) { @@ -219,12 +221,13 @@ * * @param y the row position * @return an array containing the row values + * @throws IllegalArgumentException if y is not between 0 and 8 */ public int[] getRow(int y) { if (y < 0 || y > 8) { throw new IllegalArgumentException("Invalid row number"); } - int row[] = new int[9]; + int[] row = new int[9]; for (int x = 0; x < 9; x++) { row[x] = getCellValue(x, y); @@ -238,12 +241,13 @@ * * @param x the column position * @return an array containing the column values + * @throws IllegalArgumentException if x is not between 0 and 8 */ public int[] getColumn(int x) { if (x < 0 || x > 8) { throw new IllegalArgumentException("Invalid column number"); } - int column[] = new int[9]; + int[] column = new int[9]; for (int y = 0; y < 9; y++) { column[y] = getCellValue(x, y);