Package api

Class 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 the State 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
    • Constructor Summary

      Constructors 
      Constructor Description
      Cell​(Cell existingCell)
      Constructs a copy of the given Cell.
      Cell​(State givenState)
      Constructs a Cell with the given state.
    • 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.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 offset
        colOffset - 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 class java.lang.Object