Class Beast

java.lang.Object
  extended by acm.graphics.GObject
      extended by acm.graphics.GTurtle
          extended by Beast
All Implemented Interfaces:
java.lang.Cloneable

public class Beast
extends acm.graphics.GTurtle

A creature that lives in our simulated world. Creatures have a physical presence in the world but are guided by their brains and their packs.

Author:
CPSC 111 instructors

Field Summary
static int DEFAULT_SIZE
          Default size of a beast, in pixels.
static int DEFAULT_SPEED
          Default distance to move in one step, in pixels.
static java.awt.Color GROOVY_COLOR
          Color when 100% groovy at full intensity.
static java.awt.Color UNGROOVY_COLOR
          Color when 100% ungroovy at full intensity.
 
Constructor Summary
Beast(IBeastBrain brain, IPackFinder packFinder)
          Construct a new beast with the given brain and packFinder.
Beast(IBeastBrain brain, IPackFinder packFinder, double x, double y, BeastMood mood, double speed)
          Create a new beast with the given data.
 
Method Summary
 void drawTurtle(java.awt.Graphics g)
          New instructions on how to draw the beast.
 int getAge()
          Fetch the beast's age
 IBeastBrain getBrain()
          Fetch the beast's current brain.
 BeastInfo getInfo()
          Fetch the beast's current info.
 BeastMood getMood()
          Fetch the beast's current mood.
 IPackFinder getPackFinder()
          Fetch the beast's current pack finder.
 void setBrain(IBeastBrain brain)
          Set the beast's current brain.
 void setMood(BeastMood mood)
          Set the beast's current mood.
 void setPackFinder(IPackFinder packFinder)
          Set the beast's current pack finder.
 void update()
          Update this beast to its next step.
 
Methods inherited from class acm.graphics.GTurtle
contains, erasePath, forward, forward, getBounds, getDirection, getSpeed, getTurtleSize, hideTurtle, isPenDown, isTurtleVisible, left, main, move, paint, penDown, penUp, right, setColor, setDirection, setLocation, setSize, setSpeed, showTurtle
 
Methods inherited from class acm.graphics.GObject
addActionListener, addMouseListener, addMouseMotionListener, contains, fireActionEvent, fireActionEvent, getColor, getHeight, getLocation, getParent, getSize, getWidth, getX, getY, isVisible, movePolar, pause, removeActionListener, removeMouseListener, removeMouseMotionListener, sendBackward, sendForward, sendToBack, sendToFront, setLocation, setVisible, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GROOVY_COLOR

public static final java.awt.Color GROOVY_COLOR
Color when 100% groovy at full intensity.


UNGROOVY_COLOR

public static final java.awt.Color UNGROOVY_COLOR
Color when 100% ungroovy at full intensity.


DEFAULT_SPEED

public static final int DEFAULT_SPEED
Default distance to move in one step, in pixels.

See Also:
Constant Field Values

DEFAULT_SIZE

public static final int DEFAULT_SIZE
Default size of a beast, in pixels.

See Also:
Constant Field Values
Constructor Detail

Beast

public Beast(IBeastBrain brain,
             IPackFinder packFinder)
Construct a new beast with the given brain and packFinder.

Parameters:
brain - a non-null brain to use for the beast
packFinder - a non-null packFinder to use for the beast

Beast

public Beast(IBeastBrain brain,
             IPackFinder packFinder,
             double x,
             double y,
             BeastMood mood,
             double speed)
Create a new beast with the given data.

Parameters:
brain - the beast's brain (non-null)
packFinder - the beast's pack finder (non-null)
x - the beast's starting x position
y - the beast's starting x position
mood - the beast's mood (may be null for a default mood)
speed - the beast's speed
Method Detail

getPackFinder

public IPackFinder getPackFinder()
Fetch the beast's current pack finder.

Returns:
the current pack finder

setPackFinder

public void setPackFinder(IPackFinder packFinder)
Set the beast's current pack finder.

Parameters:
packFinder - the new pack finder (non-null)

getInfo

public BeastInfo getInfo()
Fetch the beast's current info. The info fully describes the beast's state without allowing changes to that state.

Returns:
the beast's current info

getAge

public int getAge()
Fetch the beast's age

Returns:
the beast's age in number of steps taken

getBrain

public IBeastBrain getBrain()
Fetch the beast's current brain.

Returns:
the beast's current brain

setBrain

public void setBrain(IBeastBrain brain)
Set the beast's current brain.

Parameters:
brain - the new brain (non-null)

getMood

public BeastMood getMood()
Fetch the beast's current mood.

Returns:
the beast's current mood (may be null for default mood)

setMood

public void setMood(BeastMood mood)
Set the beast's current mood.

Parameters:
mood - the new mood (may be null for default mood)

update

public void update()
Update this beast to its next step.

Note: remember that beast's MUST be supplied non-null brains and packFinders in their constructors. If either was null, the error is likely to show up here.


drawTurtle

public void drawTurtle(java.awt.Graphics g)
New instructions on how to draw the beast.

Overrides:
drawTurtle in class acm.graphics.GTurtle