Package api
Class Cell
- java.lang.Object
-
- api.Cell
-
public class Cell extends java.lang.Object
Represents one cell of the Pearls game grid. A cell always has a state, represented by one of theState
constants, and has an attribute indicating whether or not the player is present in the cell. There are also two attributes, a row offset and a column offset, that are only meaningful when the Cell's state is PORTAL. (The offsets give the vertical and horizontal shift to the companion portal.)- Author:
- smkautz
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getColumnOffset()
Returns the column offset for this cell.int
getRowOffset()
Returns the row offset for this cell.State
getState()
Returns the state for this cell.boolean
isPlayerPresent()
Determines whether or not the player is present in this cell.void
setOffsets(int rowOffset, int colOffset)
Sets the row and column offsets for this cell.void
setPlayerPresent(boolean isPresent)
Sets whether or not the player is present in this cell.void
setState(State givenState)
Sets the state for this cell.java.lang.String
toString()
Returns a string representation of this Cell.
-
-
-
Constructor Detail
-
Cell
public Cell(State givenState)
Constructs a Cell with the given state. Initially the row and column offsets are zero and player is not present.- Parameters:
givenState
- state for this Cell
-
Cell
public Cell(Cell existingCell)
Constructs a copy of the given Cell.- Parameters:
existingCell
- original to be copied
-
-
Method Detail
-
getState
public State getState()
Returns the state for this cell.- Returns:
- state for this cell
-
setState
public void setState(State givenState)
Sets the state for this cell.- Parameters:
givenState
- new state for this cell
-
getColumnOffset
public int getColumnOffset()
Returns the column offset for this cell.- Returns:
- column offset for this cell
-
getRowOffset
public int getRowOffset()
Returns the row offset for this cell.- Returns:
- row offset for this cell
-
setOffsets
public void setOffsets(int rowOffset, int colOffset)
Sets the row and column offsets for this cell.- Parameters:
rowOffset
- given row offsetcolOffset
- given column offset
-
isPlayerPresent
public boolean isPlayerPresent()
Determines whether or not the player is present in this cell.- Returns:
- true if player is present, false otherwise
-
setPlayerPresent
public void setPlayerPresent(boolean isPresent)
Sets whether or not the player is present in this cell.- Parameters:
isPresent
- true if player is present, false otherwise
-
toString
public java.lang.String toString()
Returns a string representation of this Cell.- Overrides:
toString
in classjava.lang.Object
-
-