Class Sim
java.lang.Object
Sim
The simulation keeps track of the field and simulation-related things, like
the current step.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Sim
(int rows, int cols) Create a new simulation with a field with the specified dimensions. -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(javafx.scene.canvas.GraphicsContext g, int cellsize) Draw the current state of the simulation.int
getStep()
Return the current simulation step number.boolean
isOver()
Is the simulation over?void
reset()
Reset the simulation.void
step()
Advance the simulation one step.
-
Field Details
-
field_
-
step_
protected int step_
-
-
Constructor Details
-
Sim
protected Sim(int rows, int cols) Create a new simulation with a field with the specified dimensions.- Parameters:
rows
- rows in the fieldcols
- columns in the field
-
-
Method Details
-
reset
public void reset()Reset the simulation. -
getStep
public int getStep()Return the current simulation step number.- Returns:
- current simulation step number
-
step
public void step()Advance the simulation one step. (Does not include repainting.) -
isOver
public boolean isOver()Is the simulation over?- Returns:
- true if the simulation is over, false otherwise
-
draw
public void draw(javafx.scene.canvas.GraphicsContext g, int cellsize) Draw the current state of the simulation.- Parameters:
g
- graphics contextcellsize
- size (in pixels) for one grid cell
-