org.univ.paris5.GameOfLife
Class GridWorld

java.lang.Object
  extended by org.univ.paris5.GameOfLife.GridWorld
All Implemented Interfaces:
Grid

public class GridWorld
extends java.lang.Object
implements Grid

Contains the cellgrid, the current shape and the Game Of Life algorithm that changes it.


Constructor Summary
GridWorld(Algorithm algorithm, int cellCols, int cellRows)
          Instance of GridWorld.
 
Method Summary
 void clear()
          Clears grid.
 java.awt.Dimension getDimension()
          Get dimension of cellgrid.
 java.util.Enumeration getEnum()
          Get cell-enumerator.
 int getGenerations()
          Get number of generations.
 Cell getNeighbour(int c, int r)
          Get Objet Cell with the possition.
 int getPopulation()
          Get number population.
 int getRandomCell(int n)
          Get Random number for state index.
 java.util.Hashtable getShape()
          Get cell-Hashtable.
 State getStateCell(int col, int row)
          Get status of cell.
 void initCell(boolean random)
          Init all cell for state random
 void next()
          Create next generation of shape.
 void random()
          Clears grid.
 void resize(int col, int row)
          Resize the cell grid.
 void setAlgorithm(Algorithm algo)
           
 void setCell(int col, int row, State state)
          Set status of cell (alive or dead).
 void setShape(java.util.Hashtable shape)
          Set cell-Hashtable.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridWorld

public GridWorld(Algorithm algorithm,
                 int cellCols,
                 int cellRows)
Instance of GridWorld.

Parameters:
algorithm -
cellCols -
cellRows -
Method Detail

initCell

public void initCell(boolean random)
Init all cell for state random

Parameters:
random -

getRandomCell

public int getRandomCell(int n)
Get Random number for state index.

Parameters:
n - number-state
Returns:
index

getStateCell

public State getStateCell(int col,
                          int row)
Get status of cell.

Specified by:
getStateCell in interface Grid
Parameters:
col - x-position
row - y-position
Returns:
living or not

setCell

public void setCell(int col,
                    int row,
                    State state)
Set status of cell (alive or dead).

Specified by:
setCell in interface Grid
Parameters:
col - x-position
row - y-position
cell - living or not

getNeighbour

public Cell getNeighbour(int c,
                         int r)
Get Objet Cell with the possition.

Parameters:
c -
r -
Returns:

next

public void next()
Create next generation of shape.


clear

public void clear()
Clears grid.

Specified by:
clear in interface Grid

random

public void random()
Clears grid.


resize

public void resize(int col,
                   int row)
Resize the cell grid.

Specified by:
resize in interface Grid
Parameters:
col - new number of columns.
row - new number of rows.

getGenerations

public int getGenerations()
Get number of generations.

Returns:
number of generations

getDimension

public java.awt.Dimension getDimension()
Get dimension of cellgrid.

Specified by:
getDimension in interface Grid
Returns:
dimension

getEnum

public java.util.Enumeration getEnum()
Get cell-enumerator. Enumerates over all living cells (type Cell).

Specified by:
getEnum in interface Grid
Returns:
Enumerator over Cell.
See Also:
Cell

getShape

public java.util.Hashtable getShape()
Get cell-Hashtable.

Returns:
Hashtable over Cell.
See Also:
Cell

setShape

public void setShape(java.util.Hashtable shape)
Set cell-Hashtable.

Parameters:
Hashtable - shape
See Also:
Cell

setAlgorithm

public void setAlgorithm(Algorithm algo)
Parameters:
algorithm - the algorithm to set

getPopulation

public int getPopulation()
Get number population.

Returns: