Programming Assignment 10

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

Notice that a randomly chosen circle has three parameters, two locations coordinates and a diameter. 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.

You can write your program as either an application or as an applet.

This assignment is due Thrusday, November 20.


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


compliments and criticisms