Class Rabbit

java.lang.Object
  extended by Animal
      extended by Rabbit

public class Rabbit
extends Animal

A simple model of a rabbit. Rabbits age, move, breed, and die.

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

Constructor Summary
Rabbit(boolean randomAge, Field field, Location location)
          Create a new rabbit.
 
Method Summary
 void act(List<Animal> newRabbits)
          This is what the rabbit does most of the time - it runs around.
 
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

Rabbit

public Rabbit(boolean randomAge,
              Field field,
              Location location)
Create a new rabbit. A rabbit may be created with age zero (a new born) or with a random age.

Parameters:
randomAge - If true, the rabbit will have a random age.
field - The field currently occupied.
location - The location within the field.
Method Detail

act

public void act(List<Animal> newRabbits)
This is what the rabbit does most of the time - it runs around. Sometimes it will breed or die of old age.

Specified by:
act in class Animal
Parameters:
newRabbits - A list to return newly born rabbits.