Class Block

java.lang.Object
  extended by BoxedBallsObject
      extended by StationaryObject
          extended by Block
All Implemented Interfaces:
DrawableFigure, Polygon

public class Block
extends StationaryObject
implements Polygon

Creates a stationary object "Wall," which is a polygon, and implements interface Polygon.


Field Summary
 
Fields inherited from class StationaryObject
STATIONARY_OBJECT_MASS, STATIONARY_OBJECT_VELOCITY
 
Constructor Summary
Block()
          initializes Block as a rectangle with all coordinates at (0,0)
Block(String s, Color c, int[] newXPolygon, int[] newYPolygon, int newNumberOfPoints)
          Creates a polygonal block.
 
Method Summary
 void draw(Graphics canvas)
          Draws the block onto Graphics object canvas.
 int[] getXCoordinates()
           
 int[] getYCoordinates()
           
 void setCoordinates(int[] x, int[] y, int n)
          sets coordinates of polygon
 
Methods inherited from class StationaryObject
getColor, getMass, getXVelocity, getYVelocity
 
Methods inherited from class BoxedBallsObject
getName, setColor, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Block

public Block()
initializes Block as a rectangle with all coordinates at (0,0)


Block

public Block(String s,
             Color c,
             int[] newXPolygon,
             int[] newYPolygon,
             int newNumberOfPoints)
Creates a polygonal block.

Parameters:
name - s, color c
newXPolygon - an array of x values
newYPolygon - an array of y values
Method Detail

setCoordinates

public void setCoordinates(int[] x,
                           int[] y,
                           int n)
Description copied from interface: Polygon
sets coordinates of polygon

Specified by:
setCoordinates in interface Polygon

getXCoordinates

public int[] getXCoordinates()

getYCoordinates

public int[] getYCoordinates()

draw

public void draw(Graphics canvas)
Draws the block onto Graphics object canvas. The block is filled with a solid color.

Specified by:
draw in interface DrawableFigure