Better docstrings
This commit is contained in:
parent
f84cccc1b5
commit
56ab2ca98f
1 changed files with 16 additions and 7 deletions
|
@ -7,10 +7,16 @@ public class Solver implements SudokuSolver {
|
||||||
board = new int[9][9];
|
board = new int[9][9];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public void setBoard(int[][] board) {
|
public void setBoard(int[][] board) {
|
||||||
this.board = board;
|
this.board = board;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public int[][] getBoard() {
|
public int[][] getBoard() {
|
||||||
return board;
|
return board;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +28,9 @@ public class Solver implements SudokuSolver {
|
||||||
board = new int[9][9];
|
board = new int[9][9];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public boolean solve() {
|
public boolean solve() {
|
||||||
return solve(0, 0);
|
return solve(0, 0);
|
||||||
}
|
}
|
||||||
|
@ -96,12 +105,7 @@ public class Solver implements SudokuSolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if val is legal in the given row, column, and 3x3 box
|
* {@inheritDoc}
|
||||||
*
|
|
||||||
* @param row row to check
|
|
||||||
* @param col column to check
|
|
||||||
* @param val value to check
|
|
||||||
* @return true if val is legal
|
|
||||||
*/
|
*/
|
||||||
public boolean legal(int row, int col, int val) {
|
public boolean legal(int row, int col, int val) {
|
||||||
if (row < 0 || row >= 9 || col < 0 || col >= 9 || val < 1 || val > 9) {
|
if (row < 0 || row >= 9 || col < 0 || col >= 9 || val < 1 || val > 9) {
|
||||||
|
@ -138,6 +142,11 @@ public class Solver implements SudokuSolver {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the board is solved
|
||||||
|
*
|
||||||
|
* @return true if solved
|
||||||
|
*/
|
||||||
public boolean isSolved() {
|
public boolean isSolved() {
|
||||||
return isSolved(0, 0);
|
return isSolved(0, 0);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +156,7 @@ public class Solver implements SudokuSolver {
|
||||||
*
|
*
|
||||||
* @param row
|
* @param row
|
||||||
* @param col
|
* @param col
|
||||||
* @return
|
* @return true if solved
|
||||||
*/
|
*/
|
||||||
private boolean isSolved(int row, int col) {
|
private boolean isSolved(int row, int col) {
|
||||||
// If we are at the 9th row and 0th column (the last cell), we are done
|
// If we are at the 9th row and 0th column (the last cell), we are done
|
||||||
|
|
Loading…
Reference in a new issue