Breakout Problem Set Javadocs

breakout
Class DefaultBreakoutComponent

java.lang.Object
  extended bybreakout.DefaultBreakoutComponent
All Implemented Interfaces:
BreakoutComponent
Direct Known Subclasses:
Bumper, Wall

public abstract class DefaultBreakoutComponent
extends java.lang.Object
implements BreakoutComponent

abstract class DefaultBreakoutComponent provides a partial implementation of the BreakoutComponent interface. It manages the position, size, shape, death, and transient parts of the BreakoutComponent, leaving the implementation of paint and hitBy to the subclass. The shape is a rectangle.

Version:
$Id: DefaultBreakoutComponent.java,v 1.2 2004/03/26 20:39:33 gus Exp $
Author:
benmv@olin.edu
See Also:
BreakoutComponent, breakout.BenSimpleBrick

Constructor Summary
DefaultBreakoutComponent(java.awt.Point location, java.awt.Dimension size)
          without world constructor.
DefaultBreakoutComponent(java.awt.Point location, java.awt.Dimension size, World w)
          Default constructor creates the component at a given location and size.
 
Method Summary
 java.awt.Point getCenter()
          returns a point that corresponds to the center of the component.
 java.awt.Point getLocation()
          returns a new Point corresponding to the location of the component's upper-left corner.
 java.awt.Shape getShape()
          returns a Rectangle at location with size.
 java.awt.Dimension getSize()
          returns the Dimensions of the component.
abstract  void hitBy(BreakoutComponent striker)
          subclasses must implement the hitBy method to have the component react to being struck.
 boolean isDead()
          returns dead status of component.
 boolean isTransient()
          The default component is not transient.
 void kill()
          destroys this component
abstract  void paint(java.awt.Graphics g)
          subclasses must implement the paint method in order to draw their component.
 void setLocation(java.awt.Point location)
          changes the location of the component's upper left corner to the given location.
 void setWorld(World world)
          sets the world the component lives in
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultBreakoutComponent

public DefaultBreakoutComponent(java.awt.Point location,
                                java.awt.Dimension size,
                                World w)
Default constructor creates the component at a given location and size.

Parameters:
location - Initial location of component.
size - Initial size of component.
w - World the component lives in.

DefaultBreakoutComponent

public DefaultBreakoutComponent(java.awt.Point location,
                                java.awt.Dimension size)
without world constructor.

Method Detail

getLocation

public java.awt.Point getLocation()
returns a new Point corresponding to the location of the component's upper-left corner. Changing the returned point will NOT result in the component's location changing. To change the location of this component, use setLocation.

Specified by:
getLocation in interface BreakoutComponent
Returns:
New Point corresponding to location of component.

setLocation

public void setLocation(java.awt.Point location)
changes the location of the component's upper left corner to the given location. Copies the given point, so subsequent changes to the Point provided will not affect the location of the compenent.

Specified by:
setLocation in interface BreakoutComponent
Parameters:
location - Point to locate the component at.

getCenter

public java.awt.Point getCenter()
returns a point that corresponds to the center of the component. getLocation() returns upper-left corner.

Specified by:
getCenter in interface BreakoutComponent
Returns:
Point located at the center of the component.

getSize

public java.awt.Dimension getSize()
returns the Dimensions of the component. Mutating the returned value will NOT change the size of the component.

Specified by:
getSize in interface BreakoutComponent
Returns:
Dimension of the component.

getShape

public java.awt.Shape getShape()
returns a Rectangle at location with size.

Specified by:
getShape in interface BreakoutComponent
Returns:
Shape Rectangle according to components location and size.

kill

public void kill()
Description copied from interface: BreakoutComponent
destroys this component

Specified by:
kill in interface BreakoutComponent

isDead

public boolean isDead()
Description copied from interface: BreakoutComponent
returns dead status of component.

Specified by:
isDead in interface BreakoutComponent

isTransient

public boolean isTransient()
The default component is not transient.

Specified by:
isTransient in interface BreakoutComponent
Returns:
false by default.

setWorld

public void setWorld(World world)
Description copied from interface: BreakoutComponent
sets the world the component lives in

Specified by:
setWorld in interface BreakoutComponent

paint

public abstract void paint(java.awt.Graphics g)
subclasses must implement the paint method in order to draw their component.

Specified by:
paint in interface BreakoutComponent
Parameters:
g - Graphics object used to draw with.

hitBy

public abstract void hitBy(BreakoutComponent striker)
subclasses must implement the hitBy method to have the component react to being struck.

Specified by:
hitBy in interface BreakoutComponent
Parameters:
striker - BreakoutComponent that struck this component

Breakout Problem Set Javadocs