Package sudoku
Class Sudoku
- java.lang.Object
-
- sudoku.Sudoku
-
public class Sudoku extends Object
Class representing Sudoku riddle.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Sudoku.DigitImmutableException
Custom exception thrown when trying to modify hard-coded sudoku field.static class
Sudoku.DigitOutOfRangeException
Custom exception thrown when a board digit is negative or greater than sudoku rank (0 indicates an empty field).static class
Sudoku.IncorrectBoardSizeException
Custom exception thrown when trying to initialize board with incorrect size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
int[][]
getBoard()
int
getDigit(int x, int y)
int
getEmptyFieldsCount()
boolean
getMask(int x, int y)
int
getPlayerCount()
int
getRank()
int
getSize()
int
getTableCount()
void
insertDigit(int x, int y, int digit)
void
printNatural()
Prints the board of the Sudoku in natural, human-friendly style.void
reset()
Reset board to default state.void
setBoard(int[][] board)
Set board default state.
-
-
-
Field Detail
-
_rank
private final int _rank
Size of a single (small) sudoku square (aka. block)
-
_size
private final int _size
Board size
-
_board
private int[][] _board
Current values of board fields
-
_mask
private boolean[][] _mask
Array of flags indicating hard-coded board fields. If true, field cannot be modified.
-
-
Constructor Detail
-
Sudoku
public Sudoku(int rank)
-
Sudoku
public Sudoku(Sudoku sudoku)
-
-
Method Detail
-
getBoard
public int[][] getBoard()
-
setBoard
public void setBoard(int[][] board)
Set board default state.- Parameters:
board
- 2d array of sudoku digits (0 means that the field is empty)
-
reset
public void reset()
Reset board to default state. Sets all unmasked board fields to zero (empty).
-
insertDigit
public void insertDigit(int x, int y, int digit)
-
getDigit
public int getDigit(int x, int y)
-
getMask
public boolean getMask(int x, int y)
-
getSize
public int getSize()
-
getRank
public int getRank()
-
getPlayerCount
public int getPlayerCount()
-
getTableCount
public int getTableCount()
-
getEmptyFieldsCount
public int getEmptyFieldsCount()
-
printNatural
public void printNatural()
Prints the board of the Sudoku in natural, human-friendly style.
-
-