Class Animal

java.lang.Object
  extended by Animal

public abstract class Animal
extends java.lang.Object

A class representing shared characteristics of animals.

Version:
2008.03.30
Author:
David J. Barnes and Michael Kolling

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

Animal

public Animal(Field field,
              Location location)
Create a new animal at location in field.

Parameters:
field - The field currently occupied.
location - The location within the field.
Method Detail

act

public abstract void act(java.util.List<Animal> newAnimals)
Make this animal act - that is: make it do whatever it wants/needs to do.

Parameters:
newAnimals - A list to add newly born animals to.

getField

public Field getField()
Return the animal's field.

Returns:
The animal's field.

getLocation

public Location getLocation()
Return the animal's location.

Returns:
The animal's location.

isAlive

public boolean isAlive()
Check whether the animal is alive or not.

Returns:
true if the animal is still alive.

setDead

public void setDead()
Indicate that the animal is no longer alive. It is removed from the field.


setLocation

public void setLocation(Location newLocation)
Place the animal at the new location in the given field.

Parameters:
newLocation - The animal's new location.