life
Class Cell

java.lang.Object
  extended by life.Cell

public class Cell
extends java.lang.Object

Models a cell in Conway's Game of Life.

Author:
Tom James

Field Summary
private  boolean flagState
          Whether or not the cell is flagged to be changed.
private  int positionX
          The x-coordinate of the cell.
private  int positionY
          The y-coordinate of the cell.
private  boolean state
          Whether or not the cell is alive.
 
Constructor Summary
Cell(int x, int y, boolean state)
          Constructs a cell given an x-coordinate, y-coordinate, and state.
 
Method Summary
 void changeState(boolean newState)
           
 void flagChangeState(boolean newState)
          Changes the cell's state to its flagState.
 boolean getFlagChangeState()
           
 int getNeighbors()
           
 double getPositionX()
           
 double getPositionY()
           
 boolean getState()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

positionX

private int positionX
The x-coordinate of the cell.


positionY

private int positionY
The y-coordinate of the cell.


state

private boolean state
Whether or not the cell is alive.


flagState

private boolean flagState
Whether or not the cell is flagged to be changed.

Constructor Detail

Cell

public Cell(int x,
            int y,
            boolean state)
Constructs a cell given an x-coordinate, y-coordinate, and state.

Parameters:
x - The x-coordinate of the cell.
y - The y-coordinate of the cell.
state - Whether or not the cell is alive.
Method Detail

getPositionX

public double getPositionX()
Returns:
The x-coordinate of the cell.

getPositionY

public double getPositionY()
Returns:
The y-coordinate of the cell.

getState

public boolean getState()
Returns:
Whether or not the cell is alive.

changeState

public void changeState(boolean newState)
Parameters:
newState - The state to which the cell will be changed.

flagChangeState

public void flagChangeState(boolean newState)
Changes the cell's state to its flagState.

Parameters:
newState - The state to which the cell will be changed.

getFlagChangeState

public boolean getFlagChangeState()
Returns:
The state to which the cell will be changed when flagChangeState() is run.

getNeighbors

public int getNeighbors()
Returns:
The number of cells neighboring the current one.