public final class Field extends Object
Board
.
Each field is marked with (a) a number (called the constraint) and
(b) an arrow (called the direction). Additionally, fields may have
colors: They can be either black or white or
uncolored. There are eight different arrows which are enumerated in
Field.Direction
. Each field is addressed by two coordinates
row
and column
denoting the row and and the column
within the board.
Board
Modifier and Type | Class and Description |
---|---|
static class |
Field.Direction
This enumeration lists the possible directions for arrows in fields of
Boards.
|
static class |
Field.FieldColor
This declaration enumerates the colors that a field can take.
|
Constructor and Description |
---|
Field(int rowParam,
int columnParam,
int constraintParam,
Field.Direction directionParam,
Field.FieldColor colorParam)
Instantiates a new field.
|
Modifier and Type | Method and Description |
---|---|
Field.FieldColor |
getColor()
Gets the color of this field.
|
int |
getColumn()
Gets the column on the board.
|
int |
getColumnOffset()
Gets the column component of the direction of the arrow as an offset.
|
int |
getConstraint()
Gets the constraint of this field.
|
Field.Direction |
getDirection()
Gets the direction.
|
List<Field> |
getRegion(Board board)
Get the region of Fields this field points to.
|
int |
getRow()
Gets the row of this field on the board.
|
int |
getRowOffset()
Gets the row component of the direction of the arrow as an offset.
|
int |
getSequentialIndex(Board board)
The sequential index of this field in the board given by the parameter, e.g. for usage as
propositional atom.
|
void |
setColor(Field.FieldColor newColor)
Sets the color of this field.
|
String |
toString() |
public Field(int rowParam, int columnParam, int constraintParam, Field.Direction directionParam, Field.FieldColor colorParam)
rowParam
- the row of this field on the board.columnParam
- the column of this field on the board.constraintParam
- the constraint in the arrow of this field.directionParam
- the direction of the arrow on this field.public int getRow()
public int getColumn()
public Field.Direction getDirection()
public int getRowOffset()
getColumnOffset()
== 0.public int getColumnOffset()
getRowOffset()
== 0.public int getConstraint()
public List<Field> getRegion(Board board)
The region is the list of Field
s to which the arrow in
this field points to. This field itself is not included in the
result.
This convenient method simply delegates to Board.getRegionForField(int, int)
.
public int getSequentialIndex(Board board)
Board.getSequentialIndex(Field)
.
So if board.containsCoordinates(this.getRow(), this.getColumn()) is met, its sequentialIndex is
returned, even if this Field is not actually on the board.IllegalArgumentException
- if
board.containsCoordinates(this.getRow(), this.getColumn()) is not met.public Field.FieldColor getColor()
null
indicating an uncolored field.Field.FieldColor.BLACK
or
Field.FieldColor.WHITE
), null
for uncolored.public void setColor(Field.FieldColor newColor)
Field.FieldColor.BLACK
newColor
- the new color of this field (i.e. Field.FieldColor.BLACK
or
Field.FieldColor.WHITE
), null
for uncolored.