Class Puck

java.lang.Object
  extended by Puck

public class Puck
extends Object

This class represents a puck object. Its instance variables represent the attributes of a puck. Its methods represent things the puck can do.

Version:
20050603
Author:
Colin Moore, Peter Gadfort

Constructor Summary
Puck(Color color, int diameter, Dimension boardSize)
          Constructor use to initialize variables
 
Method Summary
 void draw(Graphics g)
          Draws the puck on the input graphics
 Dimension getPosition()
          Returns the current position of the puck
 int getX()
          Returns the current x coordinate of the puck
 int getY()
          Returns the current y coordinate of the puck
 void move(Dimension boardSize)
          Moves the puck by incrementing the x-position by the x-component of the velocity and incrementing the y-position by the y-component of the velocity
 void reset(Dimension boardSize)
          Centers the puck on the board
 void reverseX()
          Reverses the x component of the velocity
 void reverseY()
          Reverses the y component of the velocity
 void setPosition(Dimension boardSize, int x, int y)
          Sets the position of the puck to the coordinates specified
 void setX(Dimension boardSize, int x)
          Sets the x coordinate of the puck
 void setY(Dimension boardSize, int y)
          Sets the y coordinate of the puck
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Puck

public Puck(Color color,
            int diameter,
            Dimension boardSize)
Constructor use to initialize variables

Parameters:
color - The color of the puck
diameter - The diameter of the puck
boardSize - The dimensions of the board the puck is on
Method Detail

draw

public void draw(Graphics g)
Draws the puck on the input graphics

Parameters:
g - Screen on which the puck will be drawn

getPosition

public Dimension getPosition()
Returns the current position of the puck

Returns:
The position of the puck

getX

public int getX()
Returns the current x coordinate of the puck

Returns:
The x coordinate of the puck

getY

public int getY()
Returns the current y coordinate of the puck

Returns:
The y coordinate of the puck

move

public void move(Dimension boardSize)
Moves the puck by incrementing the x-position by the x-component of the velocity and incrementing the y-position by the y-component of the velocity

Parameters:
boardSize - The dimensions of the board the puck is on

reset

public void reset(Dimension boardSize)
Centers the puck on the board

Parameters:
boardSize - The dimensions of the board the puck is on

reverseX

public void reverseX()
Reverses the x component of the velocity


reverseY

public void reverseY()
Reverses the y component of the velocity


setPosition

public void setPosition(Dimension boardSize,
                        int x,
                        int y)
Sets the position of the puck to the coordinates specified

Parameters:
boardSize - The dimensions of the board the puck is on
x - The x coordinate of the puck
y - The y coordinate of the puck

setX

public void setX(Dimension boardSize,
                 int x)
Sets the x coordinate of the puck

Parameters:
boardSize - The dimensions of the board the puck is on
x - The new x coordinate of the puck

setY

public void setY(Dimension boardSize,
                 int y)
Sets the y coordinate of the puck

Parameters:
boardSize - The dimensions of the board the puck is on
y - The new y coordinate of the puck