public class Simulator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.ArrayList<Carnivore> |
carnivorePopulation |
private static java.util.ArrayList<Herbivore> |
herbivorePopulation |
private static MapField[][] |
map |
private java.util.Random |
random |
Constructor and Description |
---|
Simulator()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
static void |
addAnimal(Animal a)
Add an animal to the population
|
static Animal |
getAnimal(int x,
int y)
Return the animal at (x, y), or null if there is no animal at that field.
|
static Carnivore |
getCarnivore(int x,
int y)
Return the carnivore at (x, y), or null if there is no animal at that field.
|
static MapField |
getField(int x,
int y)
Returns the field at the required position.
|
static Herbivore |
getHerbivore(int x,
int y)
Return the herbivore at (x, y), or null if there is no animal at that field.
|
private void |
initMap()
Initialise the map.
|
private void |
initPopulations()
Initialise the animal populations.
|
private void |
initWaterTiles()
Initialise the water tiles.
|
static void |
removeAnimal(int x,
int y,
OccupantType type)
Remove an animal from the population
|
void |
update()
Updates the model each turn.
|
void |
updateWorld()
Send the current state of the simulation on to World
|
private static java.util.ArrayList<Herbivore> herbivorePopulation
private static java.util.ArrayList<Carnivore> carnivorePopulation
private static MapField[][] map
private java.util.Random random
public void update()
public void updateWorld()
private void initMap()
private void initWaterTiles()
private void initPopulations()
public static MapField getField(int x, int y)
x,
- ypublic static Animal getAnimal(int x, int y)
public static Herbivore getHerbivore(int x, int y)
public static Carnivore getCarnivore(int x, int y)
public static void addAnimal(Animal a)
animal
- public static void removeAnimal(int x, int y, OccupantType type)
x,
- y coordinatestype
- Make sure we are removing the right animal