java.lang.ObjectAnimal
public abstract class Animal
A class representing shared characteristics of animals.
Constructor Summary | |
---|---|
Animal(Field field,
Location location)
Create a new animal at location in field. |
Method Summary | |
---|---|
abstract void |
act(java.util.List<Animal> newAnimals)
Make this animal act - that is: make it do whatever it wants/needs to do. |
Field |
getField()
Return the animal's field. |
Location |
getLocation()
Return the animal's location. |
boolean |
isAlive()
Check whether the animal is alive or not. |
void |
setDead()
Indicate that the animal is no longer alive. |
void |
setLocation(Location newLocation)
Place the animal at the new location in the given field. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Animal(Field field, Location location)
field
- The field currently occupied.location
- The location within the field.Method Detail |
---|
public abstract void act(java.util.List<Animal> newAnimals)
newAnimals
- A list to add newly born animals to.public Field getField()
public Location getLocation()
public boolean isAlive()
public void setDead()
public void setLocation(Location newLocation)
newLocation
- The animal's new location.