Package de.sfuhrm.sudoku
Interface GameMatrix
- All Known Subinterfaces:
Riddle
public interface GameMatrix
The quadratic matrix of a game field.
- Author:
- Stephan Fuhrmann
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanSet(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.Get the game schema that defines the dimensions of this matrix.intGet 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.
-
Method Details
-
getSchema
GameSchema getSchema()Get the game schema that defines the dimensions of this matrix.- Returns:
- the game schema that was used to initialize this matrix.
-
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.
-