Here are some sample files. More notes are forthcoming.
A number of you neglected to center your circles and squares on the given point. Once you realized that you were supposed to center it, most of you then figured out how to do so. (If you lost points because of this, mail me the new method and I'll update your grade.)
A few of you decided that everything should extend
Applet. However, there should only have been one applet
in your suite of classes. If you did extend
is likely that you found it difficult to write
What else? I'm still seeing some problems with comments and indentation. I'm likely to get fairly nasty on the next assignment. (Now that you've used Javadoc, you understand some of my conventions.)
Some of you wanted to get the bounds of the graphics area, but couldn't figure out a way to do so. If you carefully read the documentation, you will find that you might be able to do the following.
Rectangle clip = g.getClipBounds();
int leftBorder = clip.x; int topBorder = clip.y; int width = clip.width; int height = clip.height;
int x = leftBorder + (Math.abs(generator.nextInt()) % width); int y = topBorder + (Math.abs(generator.nextInt()) % width);
You may want to think if I got everything right (particularly the last step).
As you have hopefully noted from the reading, component testing is quite
important. Hence, two two basic components (
Square) have individual testers. There is not a tester
DrawingAssistant because the
applet does the testing.
Note that you should be fairly careful in your testing and analysis. If there are two different constructors, check to see what each one does. If there is a chance that a method affects its arguments, check afterwards.
As an example of the kind of thing you might have done for some extra
credit, I've created a
NewCircle class that outlines
the circle in the ``complement'' of the circle's main color.
This is just an example of fun with the random drawing mechanism. It illustrates some of the problems with that mechanism. (Try covering up parts of the picture.) You can run it with
We can simplify the design of the program by using inheritance. We'll discuss this in class.
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/notes.03.html
Source text last modified Wed Feb 17 09:38:51 1999.
This page generated on Wed Feb 17 09:40:49 1999 by SiteWeaver. Validate this page's HTML.
Contact our webmaster at firstname.lastname@example.org