CSE115.FishBowl
Class Fish

java.lang.Object
  extended by CSE115.FishBowl.MovingBodyAdapter
      extended by CSE115.FishBowl.Fish
All Implemented Interfaces:
MovingBody, Shape, MouseListener, MouseMotionListener, EventListener, Colorable, Graphic, Locatable, Reactor, Rotatable, Sizeable

public class Fish
extends MovingBodyAdapter

A Fish that moves when told to. Created: Thu Sep 29 15:00:55 2005

Version:
1.3
Author:
Carl Alphonce

Field Summary
 
Fields inherited from interface NGP.Colorable
DEFAULT_GRAY
 
Constructor Summary
Fish()
          Creates a new Fish instance.
 
Method Summary
 int getSize()
          Returns the size of the Fish.
 void setSize(int size)
          Sets the size of the Fish.
 void update()
          Update the position and orientation of the fish based on the velocity.
 
Methods inherited from class CSE115.FishBowl.MovingBodyAdapter
contains, getBounds, getCenterLocation, getColor, getDimension, getDrawingPanel, getDx, getDy, getLocation, getRotation, hide, intersects, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, paint, react, setBackgroundColor, setColor, setDimension, setDrawingPanel, setFrameDelay, setLocation, setRotation, setVelocity, show, startBouncing, stopBouncing
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Fish

public Fish()
Creates a new Fish instance.

Method Detail

getSize

public int getSize()
Returns the size of the Fish.

Returns:
the size of the Fish.

setSize

public void setSize(int size)
Sets the size of the Fish.

Parameters:
size - the new size of the Fish (must be greater than 0).

update

public void update()
Update the position and orientation of the fish based on the velocity. If the fish hits a wall, it reverses velocity in the appropriate direction and points in the appropriate direction too.

Specified by:
update in interface MovingBody
Overrides:
update in class MovingBodyAdapter