Class PongPaddle

java.lang.Object
  |
  +--PongPaddle

public class PongPaddle
extends java.lang.Object

This class describes objects that represent the paddles in a Pong game. Each PongPaddle has an (x,y) position that indicates the position of the top-left corner of the paddle. Each PongPaddle also has a width and a height.


Constructor Summary
PongPaddle(int top, int left, int w, int h)
          Construct a new PongPaddle at the specified position with the specified width and height.
 
Method Summary
 int getBottomY()
          Return the Y coordinate of the bottom edge of this PongPaddle.
 int getLeftX()
          Return the X coordinate of the left edge of this PongPaddle.
 int getRightX()
          Return the X coordinate of the right edge of this PongPaddle.
 int getTopY()
          Return the Y coordinate of the top edge of this PongPaddle.
 void moveDown(int d)
          Move the position of this PongPaddle down by the specified number of pixels.
 void moveUp(int d)
          Move the position of this PongPaddle up by the specified number of pixels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PongPaddle

public PongPaddle(int top,
                  int left,
                  int w,
                  int h)
Construct a new PongPaddle at the specified position with the specified width and height.

Parameters:
top - the Y coordinate of the top left corner of the new PongPaddle.
left - the X coordinate of the top left corner of the new PongPaddle.
w - the width of the new PongPaddle, measured in pixels.
h - the height of the new PongPaddle, measured in pixels.
Method Detail

getBottomY

public int getBottomY()
Return the Y coordinate of the bottom edge of this PongPaddle.

Returns:
the Y coordinate of the bottom edge of this PongPaddle.

getLeftX

public int getLeftX()
Return the X coordinate of the left edge of this PongPaddle.

Returns:
the X coordinate of the left edge of this PongPaddle.

getRightX

public int getRightX()
Return the X coordinate of the right edge of this PongPaddle.

Returns:
the X coordinate of the right edge of this PongPaddle.

getTopY

public int getTopY()
Return the Y coordinate of the top edge of this PongPaddle.

Returns:
the Y coordinate of the top edge of this PongPaddle.

moveDown

public void moveDown(int d)
Move the position of this PongPaddle down by the specified number of pixels.

Parameters:
d - a number of pixels.

moveUp

public void moveUp(int d)
Move the position of this PongPaddle up by the specified number of pixels.

Parameters:
d - a number of pixels.