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 classSudoku.DigitImmutableExceptionCustom exception thrown when trying to modify hard-coded sudoku field.static classSudoku.DigitOutOfRangeExceptionCustom exception thrown when a board digit is negative or greater than sudoku rank (0 indicates an empty field).static classSudoku.IncorrectBoardSizeExceptionCustom exception thrown when trying to initialize board with incorrect size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)int[][]getBoard()intgetDigit(int x, int y)intgetEmptyFieldsCount()booleangetMask(int x, int y)intgetPlayerCount()intgetRank()intgetSize()intgetTableCount()voidinsertDigit(int x, int y, int digit)voidprintNatural()Prints the board of the Sudoku in natural, human-friendly style.voidreset()Reset board to default state.voidsetBoard(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.
-
-