| Modifier and Type | Field and Description |
|---|---|
protected static int |
BLOCK_SIZE
The edge dimension of a 3x3 block.
|
static int |
SIZE
The size in one dimension.
|
static byte |
UNSET
The value that is assigned to unset fields.
|
| Constructor and Description |
|---|
GameMatrix()
Creates an empty riddle.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
block(int row,
int column,
byte[] target)
Gets a stream of the given block.
|
boolean |
canSet(int row,
int column,
byte value)
Checks if the effect of one set operation is valid.
|
void |
clear()
Clear the cells.
|
Object |
clone() |
protected void |
column(int index,
byte[] target)
Gets a stream of the given column.
|
boolean |
equals(Object obj) |
byte |
get(int row,
int column)
Get the value of a field.
|
byte[][] |
getArray()
Gets a copy of the underlying array.
|
int |
getSetCount()
Get the number of set cells.
|
int |
hashCode() |
boolean |
isValid()
Checks if the whole play field is valid.
|
static byte[][] |
parse(String... rows)
Parses a string based field descriptor.
|
protected void |
row(int index,
byte[] target)
Gets a stream of the given row.
|
void |
set(int row,
int column,
byte value)
Set the value of a field.
|
void |
setAll(byte[][] initializationData)
Sets all cells to the given values.
|
String |
toString() |
public static final byte UNSET
public static final int SIZE
protected static final int BLOCK_SIZE
public GameMatrix()
setAll(byte[][])public final void setAll(byte[][] initializationData)
initializationData - initialization data with the first dimension
being the rows and the second dimension being the columns.protected void row(int index,
byte[] target)
index - the row index to get the stream for.target - a 9-element array to receive the row data.protected void column(int index,
byte[] target)
index - the column index to get the stream for.target - a 9-element array to receive the column data.protected void block(int row,
int column,
byte[] target)
row - start row of the block (0..6).column - start column of the block (0..6).target - a 9-element array to receive the block data.public static final byte[][] parse(String... rows)
rows - array of strings with each string describing a row. Digits
get converted to the element values, everything else gets converted to
UNSET.IllegalArgumentException - if one of the rows has a wrong size.public void clear()
public final byte get(int row,
int column)
row - the row of the cell to get the value for.column - the column of the cell to get the value for.public void set(int row,
int column,
byte value)
column - the column of the field.row - the row of the field.value - the value of the field.public int getSetCount()
public byte[][] getArray()
public final boolean isValid()
true if the filled rows, columns and blocks contain no duplicate numbers.public final boolean canSet(int row,
int column,
byte value)
isValid().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.true if the given cell can be set to value without
violating the game rules.Copyright © 2017. All rights reserved.