|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object WatorWorld.WatorWorld
public class WatorWorld
Provides a simulation of a Wat-or World as described by A.K. Dewdney in his Scientific American article: Sharks and fish wage an ecological war on the toroidal planet Wa-Tor.
Constructor Summary | |
---|---|
WatorWorld(int rows,
int cols,
double fractionFish,
double fractionSharks)
Create a new Watorworld. |
Method Summary | |
---|---|
Color |
getColor(int row,
int col)
Return the color of the Actor at the specified cell. |
int |
getNumCols()
Get the number of columns in this world. |
int |
getNumFish()
Return the number of fish in the simulation. |
int |
getNumRows()
Get the number of rows in this world. |
int |
getNumSharks()
Return the number of sharks in the simulation. |
int |
getNumSpots()
Get the total number of cells in this world. |
static Color |
getOceanColor()
|
void |
reset(double fractionFish,
double fractionSharks)
Reset the world. |
void |
step()
Perform one step of the simulation. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WatorWorld(int rows, int cols, double fractionFish, double fractionSharks)
rows
- rows > 0, number of rows in worldcols
- cols > 0, number of cols in worldfractionFish
- The fraction of the world initially populated by Fish.fractionSharks
- The fraction of the world initially populated by Sharks.Method Detail |
---|
public static Color getOceanColor()
public void reset(double fractionFish, double fractionSharks)
fractionFish
- The fraction of the world initially populated by Fish.fractionSharks
- The fraction of the world initially populated by Sharks.public void step()
public int getNumFish()
public int getNumSharks()
public Color getColor(int row, int col)
row
- the row valuecol
- the column value
public int getNumRows()
public int getNumCols()
public String toString()
toString
in class Object
public int getNumSpots()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |