CS 161 Assignment #4

Due Monday, October 5th by 11:59pm
(Not accepted after October 7th at noon)

Introduction

You're on a roll! Your alarm clock class has been hugely successful and, at a recent cocktail party, someone introduced you to Bill Gates. Turns out he's a big fan of your work, and had heard that you've dabbled with CircleDrawers. He's asked you to implement a new and improved version of CircleDrawer that can track an unlimited number of Circles instead of just two. The collection of circles can be made visible or invisible, moved around the screen as a group, etc. With Chapter 4 (and the improved Notebook project) fresh in your head, you agree to the project...

The Assignment

I've created a new project to get you started. Please download and modify SuperCircleDrawer instead of creating a new project via BlueJ, otherwise you won't be able to submit the assignment when you're finished. The new project contains Circle (with the new getDiameter accessor), and a version of Canvas with a larger drawing area. Your SuperCircleDrawer class should contain the following methods: Note: It should be possible to invoke any of the methods above on an empty collection of circles without getting an error message. Obviously, if drawLargestCircle is invoked before any circles are added to the group, for example, nothing should be drawn on the screen, but it shouldn't produce an error message from Java either.

Comments

Each and every method should have a "javadoc-style" comment above it (the ones that use /** ... */). For full credit, you should use the @param and @return tags as appropriate in these method comments. Each instance variable (field) should have a brief comment as well. Don't forget the main comment at the top of the class either — I'm looking for more than just a sentence or two.

Extending the Assignment

There's no extra credit, but you'll sleep better after completing this: Add a method called addRandomCircles that takes a single integer as its argument. It should create and add the specified number of random circles to the collection. (The size and position should be random, and you could have several color options as well.) You can look at the guessing-game lab to see some random code in action, but the following statement assigns an integer value from 10 to 59 to the variable size:
size = (int)(Math.random()*50 + 10);

Submitting

Before submitting, test each of your methods thoroughly and double check for comments above each method. When you're convinced it's ready to go, submit the project electronically. If the submit menu item is greyed out, save this file to your desktop. Quit BlueJ, move "submission.defs" into your project folder, restart BlueJ, and try submitting again.


Brad Richards, 2009