Package de.sfuhrm.sudoku
Interface GameMatrix
-
- All Known Subinterfaces:
Riddle
public interface GameMatrixThe quadratic matrix of a game field.- Author:
- Stephan Fuhrmann
-
-
Field Summary
Fields Modifier and Type Field Description static intBLOCK_COUNTThe total number of blocks in one dimension.static intBLOCK_SIZEThe edge dimension of a 3x3 block.static byteMAXIMUM_VALUEThe valid value that is the maximum (9).static byteMINIMUM_VALUEThe valid value that is the minimum (1).static intSIZEThe size in one dimension.static intTOTAL_FIELDSThe total number of fields.static byteUNSETThe value that is assigned to unset fields.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancanSet(int row, int column, byte value)Checks if the effect of one set operation is valid.voidclear()Clear the cells.byteget(int row, int column)Get the value of a field.byte[][]getArray()Gets a copy of the underlying array.intgetSetCount()Get the number of set cells.booleanisValid()Checks if the whole play field is valid.voidset(int row, int column, byte value)Set the value of a field.voidsetAll(byte[][] initializationData)Sets all cells to the given values.static booleanvalidCoords(int row, int column)Is the coordinate pair passed valid?static booleanvalidValue(byte b)Is the value passed in valid for a field?
-
-
-
Field Detail
-
UNSET
static final byte UNSET
The value that is assigned to unset fields.- See Also:
- Constant Field Values
-
MINIMUM_VALUE
static final byte MINIMUM_VALUE
The valid value that is the minimum (1).- See Also:
- Constant Field Values
-
MAXIMUM_VALUE
static final byte MAXIMUM_VALUE
The valid value that is the maximum (9).- See Also:
- Constant Field Values
-
SIZE
static final int SIZE
The size in one dimension.- See Also:
- Constant Field Values
-
TOTAL_FIELDS
static final int TOTAL_FIELDS
The total number of fields.- See Also:
- Constant Field Values
-
BLOCK_SIZE
static final int BLOCK_SIZE
The edge dimension of a 3x3 block.- See Also:
- Constant Field Values
-
BLOCK_COUNT
static final int BLOCK_COUNT
The total number of blocks in one dimension.- See Also:
- Constant Field Values
-
-
Method Detail
-
clear
void clear()
Clear the cells.
-
get
byte get(int row, int column)Get the value of a field.- Parameters:
row- the row of the cell to get the value for.column- the column of the cell to get the value for.- Returns:
- the cell value ranging from 0 to 9.
-
set
void set(int row, int column, byte value)Set the value of a field.- Parameters:
column- the column of the field.row- the row of the field.value- the value of the field.
-
setAll
void setAll(byte[][] initializationData)
Sets all cells to the given values.- Parameters:
initializationData- initialization data with the first dimension being the rows and the second dimension being the columns.
-
getSetCount
int getSetCount()
Get the number of set cells.- Returns:
- the number of fields with a number in. Can be in the range between 0 and 81.
-
getArray
byte[][] getArray()
Gets a copy of the underlying array.- Returns:
- the data array containing numbers between 0 and 9. The first index is the row index, the second index is the column index.
-
isValid
boolean isValid()
Checks if the whole play field is valid.- Returns:
trueif the filled rows, columns and blocks contain no duplicate numbers.
-
canSet
boolean canSet(int row, int column, byte value)Checks if the effect of one set operation is valid. This is much quicker thanisValid().- Parameters:
row- the row of the cell to test validity for.column- the column of the cell to test validity for.value- the value to simulate setting for.- Returns:
trueif the given cell can be set tovaluewithout violating the game rules.
-
validValue
static boolean validValue(byte b)
Is the value passed in valid for a field?- Parameters:
b- value to check.- Returns:
trueif valid.
-
validCoords
static boolean validCoords(int row, int column)Is the coordinate pair passed valid?- Parameters:
row- the row index.column- the column index.- Returns:
trueif valid.
-
-