Class Puck


public class Puck

A Puck is a simple, pen-like object that opens a new GWindow, then allows the user move the puck in that GWindow, optionally drawing lines between Puck locations as it moves. (CSE142 Su01 HW4)

 


Constructor Summary
Puck()
          Construct a new black Puck at (200,200) with the pen down in a new GWindow.
Puck(int x, int y, boolean penDown)
          Construct a new black Puck at the given coordinates, with the pen up or down as specified, in a new GWindow.
 
Method Summary
 java.awt.Color getColor()
          Return the current line color.
 void move(int deltax, int deltay)
          Move this puck the given x and y distance relative to its current position, drawing a line with the current color from the old to new location if the pen is down.
 void moveTo(int newx, int newy)
          Move this puck to the specified coordinates, drawing a line with the current color from the old to new location if the pen is down.
 void penDown()
          Lower the pen
 boolean penIsDown()
          Return true if the pen is down, false if it is up.
 void penUp()
          Raise the pen
 void setColor(java.awt.Color newColor)
          Change the current line color to newColor
 void test()
          Test this puck by executing a sequence of method calls