Class Fox

java.lang.Object
  extended by Animal
      extended by Fox

public class Fox
extends Animal

A simple model of a fox. Foxes age, move, eat rabbits, and die.

Version:
2011.07.31
Author:
David J. Barnes and Michael Kölling

Constructor Summary
Fox(boolean randomAge, Field field, Location location)
          Create a fox.
 
Method Summary
 void act(List<Animal> newFoxes)
          This is what the fox does most of the time: it hunts for rabbits.
 
Methods inherited from class Animal
getField, getLocation, isAlive, setDead, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Fox

public Fox(boolean randomAge,
           Field field,
           Location location)
Create a fox. A fox can be created as a new born (age zero and not hungry) or with a random age and food level.

Parameters:
randomAge - If true, the fox will have random age and hunger level.
field - The field currently occupied.
location - The location within the field.
Method Detail

act

public void act(List<Animal> newFoxes)
This is what the fox does most of the time: it hunts for rabbits. In the process, it might breed, die of hunger, or die of old age.

Specified by:
act in class Animal
Parameters:
field - The field currently occupied.
newFoxes - A list to return newly born foxes.