Assigned: Friday, February 5, 1999
Due: Friday, February 12, 1999
In this assignment, you will build a number of objects that can be used in building interesting pictures. These include two basic graphics objects (circles and squares) and a drawing assistant that helps draw objects in interesting ways.
You may work in groups of up to size four.
Create two classes,
representing circles and squares that can be drawn on the screen.
Both classes should include a
draw(int x, int y, Graphics g)
method that draws the object centered at the given point in the
given graphics object. Both classes should also include a
setColor(Color newColor) method.
You should have two constructors for
Circle. It is
up to you what color the second constructor chooses. (It could always
be the same; it could be random.)
Circle(int diameter, Color color)
Circle class should also provide
setSize(int newDiameter) and
You should also have two constructors for
again, it is up to you what color the second constructor chooses.
Square(int sideLength, Color color)
Square class should also provide
setSize(int newSideLength) and
Create a class,
DrawingAssistant that can help draw
interesting patterns with the basic graphics objects. This class
should include the following methods:
drawOne(CircleOrSquare thing, int x, int y, Graphics g)
drawSequence(CircleOrSquare thing, int n, int x, int y, int deltaX, int deltaY, Graphics g)
drawConcentric(CircleOrSquare thing, int n, int x, int y, int deltaSize, Graphics g)
drawRandom(CircleOrSquare thing, int n, Graphics g)
It is likely that you will need to take advantage of overloading and create two versions of each method, one for squares and one for circles. If you read ahead, you are also permitted to take advantage of inheritance or interfaces, which we will discuss in class 10.
Create an applet and corresponding HTML page that test your various methods.
Pick something creative. For example, you might create a
StickFigure class and extend
to support it.
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
This page may be found at http://www.math.grin.edu/~rebelsky/Courses/CS152/99S/Assignments/assign.03.html
Source text last modified Tue Feb 16 10:25:43 1999.
This page generated on Tue Feb 16 10:27:45 1999 by SiteWeaver. Validate this page's HTML.
Contact our webmaster at email@example.com