Class Deer

java.lang.Object
  extended bySimpleTurtle
      extended byTurtle
          extended byDeer

public class Deer
extends Turtle

Class that represents a deer. The deer class tracks all living deer with a linked list.

Author:
Barb Ericson ericson@cc.gatech.edu

Constructor Summary
Deer(int x, int y, ModelDisplay modelDisplayer, WolfDeerSimulation thisSim)
          Constructor that takes the x and y and a model display to draw it on
Deer(ModelDisplay modelDisplayer, WolfDeerSimulation thisSim)
          Constructor that takes the model display (the original position will be randomally assigned
 
Method Summary
 void act()
          Method to act during a time step pick a random direction and move some random amount up to top speed
 void die()
          Method that handles when a deer dies
 AgentNode getClosest(double distance, AgentNode list)
          Method to get the closest wolf within the passed distance to this deer.
 void init(WolfDeerSimulation thisSim)
          Method to initialize the new deer object
 
Methods inherited from class Turtle
square
 
Methods inherited from class SimpleTurtle
backward, drawInfoString, drop, forward, forward, getBodyColor, getDistance, getHeading, getInfoColor, getModelDisplay, getName, getPen, getPenColor, getPenWidth, getPicture, getShellColor, getShowInfo, getXPos, getYPos, hide, isPenDown, isVisible, moveTo, paintComponent, penDown, penUp, setBodyColor, setColor, setHeading, setInfoColor, setModelDisplay, setName, setPen, setPenColor, setPenDown, setPenWidth, setPicture, setShellColor, setShowInfo, setVisible, show, toString, turn, turnLeft, turnRight, turnToFace, turnToFace, updateDisplay
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Deer

public Deer(ModelDisplay modelDisplayer,
            WolfDeerSimulation thisSim)
Constructor that takes the model display (the original position will be randomally assigned

Parameters:
modelDisplayer - thing which will display the model

Deer

public Deer(int x,
            int y,
            ModelDisplay modelDisplayer,
            WolfDeerSimulation thisSim)
Constructor that takes the x and y and a model display to draw it on

Parameters:
x - the starting x position
y - the starting y position
modelDisplayer - the thing that displays the model
Method Detail

init

public void init(WolfDeerSimulation thisSim)
Method to initialize the new deer object


getClosest

public AgentNode getClosest(double distance,
                            AgentNode list)
Method to get the closest wolf within the passed distance to this deer. We'll search the input list of the kind of objects to compare to.

Parameters:
distance - the distance to look within
list - the list of agents to look at
Returns:
the closest agent in the given distance or null

act

public void act()
Method to act during a time step pick a random direction and move some random amount up to top speed


die

public void die()
Method that handles when a deer dies