DrawingGizmo
Class Specification
DrawingGizmo
Class Diagram
Invariant
A
DrawingGizmo object ...
Appears as an arrow within the Drawing
Canvas window. (This window is 260 pixels wide and 160
pixels high.)
and is either in
drawing mode or in moving mode.
Constructor
Methods
public DrawingGizmo()
post: A new DrawingGizmo object is created and
placed in the center of the Drawing Canvas
window. (Note that if two tools occupy
the same location, only one will be visible.)
and This object is set to drawing mode (and therefore colored
green).
and The
arrow for this object is pointing up.
Update Methods
public void draw()
post: This object
is set to drawing mode (and therefore colored green).
public void dontDraw()
post: This object
is set to moving mode (and therefore colored red).
public void turnClockwise()
post: This object
is rotated by 30 degrees clockwise from its previous direction.
public void turnCounterclockwise()
post: This object
is rotated by 30 degrees counterclockwise from its previous direction.
public void moveForward()
pre: At
least 20 pixels separate this object from the Drawing Canvas edge in its path
post: This object
is moved in the arrowÕs direction 20 pixels from its previous location.
and If this object is in drawing mode, a line
segment is drawn across the 20 pixel path
just traversed
public void delay2Sec()
post: The
DrawingGizmo delays all activity for 2 seconds, then resumes.
public void turnBy(int
a)
post: This object
is rotated by a degrees clockwise from
its previous direction.
public void moveBy(int
d)
pre: At
least d pixels separate this object from the Drawing Canvas edge in its path
post: This object
is moved in the arrowÕs direction d pixels from its previous location.
and If this object is in drawing mode, a line
segment is drawn across the d pixel path
just traversed
public void delayBy(int
t)
post: The
DrawingGizmo delays all activity for t milliseconds, then resumes.