ballworlds.ball
Class DudThatMoves

java.lang.Object
  extended by ballworlds.ball.Ball
      extended by ballworlds.ball.Dud
          extended by ballworlds.ball.DudThatMoves
All Implemented Interfaces:
Animate, Drawable, Relocatable
Direct Known Subclasses:
Mover

public class DudThatMoves
extends Dud

A DudThatMoves behaves exactly like a Dud (including random location), except that it moves, on its own, in a straight line (i.e., a constant velocity).

Author:
David Mutchler. Created March 20, 2009.

Constructor Summary
DudThatMoves(BallEnvironment ballEnvironment)
          Adds the DudThatMoves to its World at a random location with the default color and diameter for a DudThatMoves, and with a constant velocity.
 
Method Summary
 void act()
          Move the DudThatMoves per its constant velocity.
protected  Point2D getVelocity()
          Returns the value of the field called 'velocity'.
protected  void setVelocity(Point2D velocity)
          Sets the field called 'velocity' to the given value.
 
Methods inherited from class ballworlds.ball.Dud
die, distanceFrom, getBallEnvironment, getColor, getDiameter, getLocation, getShape, moveTo, pauseOrResume, setColor, setDiameter, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DudThatMoves

public DudThatMoves(BallEnvironment ballEnvironment)
Adds the DudThatMoves to its World at a random location with the default color and diameter for a DudThatMoves, and with a constant velocity.

Parameters:
ballEnvironment - the object that manages Balls in this World
Method Detail

act

public void act()
Move the DudThatMoves per its constant velocity.

Specified by:
act in interface Animate
Overrides:
act in class Dud

setVelocity

protected void setVelocity(Point2D velocity)
Sets the field called 'velocity' to the given value.

Parameters:
velocity - The velocity to set.

getVelocity

protected Point2D getVelocity()
Returns the value of the field called 'velocity'.

Returns:
Returns the velocity.