|
Game of Life 1.5 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.bitstorm.gameoflife.GameOfLifeGrid
Contains the cellgrid, the current shape and the Game Of Life algorithm that changes it.
| Field Summary | |
private int |
cellCols
|
private int |
cellRows
|
private java.util.Hashtable |
currentShape
Contains the current, living shape. |
private int |
generations
|
private Cell[][] |
grid
Every cell on the grid is a Cell object. |
private java.util.Hashtable |
nextShape
|
private static Shape[] |
shapes
|
| Constructor Summary | |
GameOfLifeGrid(int cellCols,
int cellRows)
Contructs a GameOfLifeGrid. |
|
| Method Summary | |
void |
addNeighbour(int col,
int row)
Adds a new neighbour to a cell. |
void |
clear()
Clears grid. |
boolean |
getCell(int col,
int row)
Get value of cell. |
java.awt.Dimension |
getDimension()
Get dimension of grid. |
java.util.Enumeration |
getEnum()
Get enumeration of Cell's |
int |
getGenerations()
Get number of generations. |
void |
next()
Create next generation of shape. |
void |
resize(int cellColsNew,
int cellRowsNew)
Resize grid. |
void |
setCell(int col,
int row,
boolean c)
Set value of cell. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private int cellRows
private int cellCols
private int generations
private static Shape[] shapes
private java.util.Hashtable currentShape
private java.util.Hashtable nextShape
private Cell[][] grid
| Constructor Detail |
public GameOfLifeGrid(int cellCols,
int cellRows)
cellCols - number of columnscellRows - number of rows| Method Detail |
public void clear()
clear in interface CellGridpublic void next()
public void addNeighbour(int col,
int row)
col - Cell-columnrow - Cell-rowpublic java.util.Enumeration getEnum()
getEnum in interface CellGridCellGrid.getEnum()
public boolean getCell(int col,
int row)
getCell in interface CellGridcol - x-coordinate of cellrow - y-coordinate of cell
public void setCell(int col,
int row,
boolean c)
setCell in interface CellGridcol - x-coordinate of cellrow - y-coordinate of cellc - value of cellpublic int getGenerations()
public java.awt.Dimension getDimension()
getDimension in interface CellGrid
public void resize(int cellColsNew,
int cellRowsNew)
resize in interface CellGridcellColsNew - new number of columns.cellRowsNew - new number of rows.CellGrid.resize(int, int)
|
Game of Life 1.5 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
This API descibes the Game of Life program, written by Edwin Martin. The source code is available online too.
Copyright 1996-2004 Edwin Martin <edwin@bitstorm.org>.