|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectsim.BasicMatrixModel
This class creates and manages a simple 2D population model.
| Constructor Summary | |
BasicMatrixModel(int r,
int c)
Using the cell counts given, create a new model. |
|
| Method Summary | |
void |
addView(MatrixView view)
Add a MatrixView to the current list of views that are looking at this model and want to hear about changes. |
static CritterInfo |
createCritterInfoInstance(Critter me,
int life,
int repro,
int maxCal,
int burn,
int strength)
Get a new instance of an object that implements the CritterInfo interface. |
Critter |
getCritter(int[] loc)
Get the Critter at the given (row,col) address in the cell array |
int[] |
getDimensions()
This method returns an int array containing the dimensions of the Matrix being modelled. |
void |
step()
Step the model one simulation step. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public BasicMatrixModel(int r,
int c)
r - number of rows of cellsc - number of columns of cells| Method Detail |
public int[] getDimensions()
MatrixModel
getDimensions in interface MatrixModelMatrixModel.getDimensions()public void addView(MatrixView view)
MatrixModel
addView in interface MatrixModelview - the MatrixView to add to the list for this modelMatrixModel.addView(MatrixView)public void step()
MatrixModel
step in interface MatrixModelMatrixModel.step()public Critter getCritter(int[] loc)
MatrixModel
getCritter in interface MatrixModelloc - a 2-element int array containing the address of the desired cell.
The row address is in element [0] and the column address is in element [1].
MatrixModel.getCritter(int[])
public static CritterInfo createCritterInfoInstance(Critter me,
int life,
int repro,
int maxCal,
int burn,
int strength)
This factory method is used instead of a constructor so that a Critter can create only one CritterInfo object to store information about itself.
me - the Critter for which this CritterInfo is being createdlife - the life span defined for this Critter, in ticksrepro - time between reproduction events in ticksmaxCal - the maximum number of calories this Critter can store.burn - the number of calories burned each tick of the clock. minimum is 1.strength - the maximum strength of this Critter in arbitrary units
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||