[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Examples] [Book] [Tutorial] [API]
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, Circle and Square,
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(int diameter)
The Circle class should also provide
setSize(int newDiameter) and getSize() methods.
You should also have two constructors for Square. Once
again, it is up to you what color the second constructor chooses.
Square(int sideLength, Color color)
Square(int diameter)
The Square class should also provide
setSize(int newSideLength) and getSize() methods.
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)
deltaSize each time.
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 DrawingAssistant
to support it.
Turn in
Email me
[Instructions] [Search] [Current] [Syllabus] [Links] [Handouts] [Outlines] [Labs] [More Labs] [Assignments] [Quizzes] [Examples] [Book] [Tutorial] [API]
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 rebelsky@math.grin.edu