Class Wolf

java.lang.Object
  extended bySimpleTurtle
      extended byTurtle
          extended byWolf

public class Wolf
extends Turtle

Class that represents a wolf. The wolf class tracks all the living wolves with a linked list.

Author:
Barb Ericson ericson@cc.gatech.edu

Constructor Summary
Wolf(int x, int y, ModelDisplay modelDisplayer)
          Constructor that takes the x and y and a model display to draw it on
Wolf(ModelDisplay modelDisplayer)
          Constructor that takes the model display (the original position will be randomly 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
 Deer getClosestDeer(double distance)
          Method to get the closest deer within the passed distance to this wolf
static Wolf getHead()
          Method to get the head of the linked list of wolves
 Wolf getNext()
          Method to get the next Wolf in the linked list
 void init()
          Method to initialize the new wolf object
static void main(java.lang.String[] args)
          main method for testing
 
Methods inherited from class SimpleTurtle
backward, backward, clearPath, drawInfoString, drop, forward, forward, getBodyColor, getDistance, getHeading, getHeight, getInfoColor, getModelDisplay, getName, getPen, getPenColor, getPenWidth, getPicture, getShellColor, getShowInfo, getWidth, getXPos, getYPos, hide, isPenDown, isVisible, moveTo, paintComponent, penDown, penUp, setBodyColor, setColor, setHeading, setHeight, setInfoColor, setModelDisplay, setName, setPen, setPenColor, setPenDown, setPenWidth, setPicture, setShellColor, setShowInfo, setVisible, setWidth, 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

Wolf

public Wolf(ModelDisplay modelDisplayer)
Constructor that takes the model display (the original position will be randomly assigned)

Parameters:
modelDisplayer - thing that displays the model

Wolf

public Wolf(int x,
            int y,
            ModelDisplay modelDisplayer)
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

getHead

public static Wolf getHead()
Method to get the head of the linked list of wolves

Returns:
the head of the linked list (may be null)

getNext

public Wolf getNext()
Method to get the next Wolf in the linked list

Returns:
the next wolf in the linked list of wolves or null

init

public void init()
Method to initialize the new wolf object


getClosestDeer

public Deer getClosestDeer(double distance)
Method to get the closest deer within the passed distance to this wolf

Parameters:
distance - the distance to look within
Returns:
the closest deer 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


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
main method for testing

Throws:
java.lang.Exception