Programming Assignment 12

Write a program that draws 750 non-overlapping randomly chosen circles, with diameters between 5 and 25, in a graphics window that is 500 pixels by 500 pixels. Here is a demonstration of what your final program should do.

To help you get started, here is a simple graphics program that draws a single random circle for each click of the button. You can do your assignment by adding code to this outline.

Notice that a randomly chosen circle has three parameters, two locations coordinates and a diameter (make sure that your non overlapping circles have their centers within the borders of the window). Your program will need to keep track of the non-overlapping circles that it has generated up to a certain point. Do this by storing the data for a circle in an object of type Drop and then having an array of type Drop[] in which you can store the data for all of the non-overlapping circles.

You will need to define the class Drop. Your Drop class should contain at least the following three methods.

   public void display(Graphics g)
   public boolean intersects(Drop drop)
   public String toString()
where display draws the circle on the graphics context g and intersects determines if this Drop intersects with the specified Drop.

This assignment is due Friday, November 10.


Return to the main homework page.
Return to the main Java page.
Return to the CS 123 home page.


compliments and criticisms