|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSugarscape.Cell
This is a component of the Sugarscape object. The Sugarscape is a 2D grid of cell objects. The number of instances is simply the product of the number of rows and columns in the grid. The object is created when the Sugarscape is first instantiated. Cells may be added or removed as the grid is resized dynamically by the user.
Field Summary | |
Citizen |
citizen
Citizen object container within the cell. |
(package private) float |
pollution
|
(package private) float |
spice
|
(package private) float |
sugar
|
Constructor Summary | |
Cell()
Constructor object, initializes quantities of sugar and spice within the cell. |
Method Summary | |
float |
getPollution()
Returns the current level of pollution in the cell. |
float |
getSpice()
Returns the current stock of spice in the cell. |
float |
getSugar()
Returns the current stock of sugar in the cell. |
boolean |
notOccupied()
Returns false when cell is occupied by a citizen. |
void |
paintCell(java.awt.Graphics g,
int x,
int y,
int cellSize)
Updates the Cell background of an empty cell. |
void |
setPollution(int actionFlag)
Recalculates pollution for the cell. |
void |
setSpice(float quantity)
Initializes the quantity of spice in a cell to a pre-specified or random amount. |
void |
setSugar(float quantity)
Initializes the quantity of sugar in a cell to a pre-specified or random amount. |
java.lang.String |
showStats(int col,
int row)
Returns a string describing the sugar, spice and pollution levels within the cell. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public Citizen citizen
Citizen
float pollution
float spice
float sugar
Constructor Detail |
public Cell()
Method Detail |
public float getPollution()
public float getSpice()
public float getSugar()
public boolean notOccupied()
public void paintCell(java.awt.Graphics g, int x, int y, int cellSize)
g
- handle to the graphics object - used to draw the grid components
including cells and citizens.x
- axis coordinate identifying the top left corner of the cell to be redrawn.y
- axis coordinate identifying the top left corner of the cell to be redrawn.cellSize
- Each cell is a square, this defines the length of one side in pixels.GoLconst.CELL_3D
public void setPollution(int actionFlag)
actionFlag
- public void setSpice(float quantity)
quantity
- value that can be positive, 0 or -1.public void setSugar(float quantity)
quantity
- value that can be positive, 0 or -1.public java.lang.String showStats(int col, int row)
col
- displays stats for cell at column identified by this valuerow
- displays stats for cell at row identified by this value
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |