ballworlds.ball
Class Dud

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

public class Dud
extends Ball

A Dud is a Ball that merely appears on the screen. Each Dud appears in a random location in its World.

Author:
David Mutchler. Created March 20, 2009.

Constructor Summary
Dud(BallEnvironment ballEnvironment)
          Adds the Dud to its World at a random location with the default color and diameter for Dud's.
 
Method Summary
 void act()
          Does anything the Animate object wishes.
 void die()
          Removes the Animate object from its World.
 double distanceFrom(Point2D point)
          Returns the distance that the Relocatable object is from the given Point2D.
protected  BallEnvironment getBallEnvironment()
          Returns the value of the field called 'ballEnvironment'.
 Color getColor()
          Returns the Color of this Drawable.
protected  double getDiameter()
          Returns the value of the field called 'diameter'.
protected  Point2D getLocation()
          Returns the value of the field called 'location'.
 Shape getShape()
          Returns the Shape (which contains position and size) of this Drawable.
 void moveTo(Point2D point)
          Moves the Relocatable object to the given Point2D, by setting its position (part of its Shape) to the given Point2D.
 void pauseOrResume()
          Toggles between the "paused" and "not-paused" state.
protected  void setColor(Color color)
          Sets the field called 'color' to the given value.
protected  void setDiameter(double diameter)
          Sets the field called 'diameter' to the given value.
protected  void setLocation(Point2D location)
          Sets the field called 'location' to the given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dud

public Dud(BallEnvironment ballEnvironment)
Adds the Dud to its World at a random location with the default color and diameter for Dud's.

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

getColor

public Color getColor()
Description copied from interface: Drawable
Returns the Color of this Drawable.

Returns:
the Color of this Drawable

getShape

public Shape getShape()
Description copied from interface: Drawable
Returns the Shape (which contains position and size) of this Drawable.

Returns:
the Shape of this Drawable

distanceFrom

public double distanceFrom(Point2D point)
Description copied from interface: Relocatable
Returns the distance that the Relocatable object is from the given Point2D.

Parameters:
point - the Point2D from which the distance is desired.
Returns:
the distance that the Relocatable object is from the given Point2D.

moveTo

public void moveTo(Point2D point)
Description copied from interface: Relocatable
Moves the Relocatable object to the given Point2D, by setting its position (part of its Shape) to the given Point2D.

Parameters:
point - the Point2D to which the Relocatable object should move.

act

public void act()
Description copied from interface: Animate
Does anything the Animate object wishes. The act() method is called repeatedly by the World to which this Animate object belongs.


die

public void die()
Description copied from interface: Animate
Removes the Animate object from its World. Thus, the Animate object is no longer asked to act and is no longer drawn.


pauseOrResume

public void pauseOrResume()
Description copied from interface: Animate
Toggles between the "paused" and "not-paused" state. During the paused state, the act() method should do nothing.


getLocation

protected final Point2D getLocation()
Returns the value of the field called 'location'.

Returns:
Returns the location.

setLocation

protected final void setLocation(Point2D location)
Sets the field called 'location' to the given value.

Parameters:
location - The location to set.

setColor

protected final void setColor(Color color)
Sets the field called 'color' to the given value.

Parameters:
color - The color to set.

getBallEnvironment

protected final BallEnvironment getBallEnvironment()
Returns the value of the field called 'ballEnvironment'.

Returns:
Returns the ballEnvironment.

getDiameter

protected final double getDiameter()
Returns the value of the field called 'diameter'.

Returns:
Returns the diameter.

setDiameter

protected final void setDiameter(double diameter)
Sets the field called 'diameter' to the given value.

Parameters:
diameter - The diameter to set.