life
Class Board

java.lang.Object
  extended by life.Board

public class Board
extends java.lang.Object

Models the board on which Conway's Game of Life is played.

Author:
Tom James

Field Summary
(package private) static int BIRTH1
          The number of neighbors required for a birth.
(package private) static int BIRTH2
          The number of neighbors required for a birth.
private  int cellCount
          The population of the board.
static Cell[][] cellList
          The two-dimensional array that stores all of the cells on the board.
(package private) static int DEATH
          The minimum number of neighbors required for a death.
private  int generation
          The current generation.
(package private) static int MINSURVIVE
          The minmum number of neighbors required to survive..
private static int size
          The length of a side of the square board.
 
Constructor Summary
Board(int x)
          Constructs a square board with side of length x.
 
Method Summary
 int getCellCount()
           
 int getGeneration()
           
static int getSize()
           
 void nextGeneration()
          Advances the board to the next generation by applying the rules of the Game of Life.
static boolean testCell(int x, int y)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

generation

private int generation
The current generation.


cellCount

private int cellCount
The population of the board.


BIRTH1

static final int BIRTH1
The number of neighbors required for a birth.

See Also:
Constant Field Values

BIRTH2

static final int BIRTH2
The number of neighbors required for a birth.

See Also:
Constant Field Values

DEATH

static final int DEATH
The minimum number of neighbors required for a death.

See Also:
Constant Field Values

MINSURVIVE

static final int MINSURVIVE
The minmum number of neighbors required to survive..

See Also:
Constant Field Values

cellList

public static Cell[][] cellList
The two-dimensional array that stores all of the cells on the board.


size

private static int size
The length of a side of the square board.

Constructor Detail

Board

public Board(int x)
Constructs a square board with side of length x.

Parameters:
x - The length of a side of the square board.
Method Detail

getGeneration

public int getGeneration()
Returns:
The current generation.

getCellCount

public int getCellCount()
Returns:
The population of the board.

getSize

public static int getSize()
Returns:
The length of a side of the board.

testCell

public static boolean testCell(int x,
                               int y)
Parameters:
x - The x-coordinate of the cell to be tested.
y - The x-coordinate of the cell to be tested.
Returns:
The state of the cell to be tested.

nextGeneration

public void nextGeneration()
Advances the board to the next generation by applying the rules of the Game of Life.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object