// Read in circle descriptions and draw them -- but don't draw them if// they overlap any of the circles that have already been drawn//// // A.B. Maccabe// March 2005// The University of New Mexico//// This program illustrates://  1) how to use the Space class, and//  2) the use of a Vector to keep track of a set of objects//// Each circle is defined by three doubles: the x and y coordinates of// the center and the radius.  The inout terminates when a circle with// a non positive radius is entered.import ann.easyio.*;			// Keyboard, Screen, ...import java.lang.*;import java.util.*;class DrawCircles extends Object{    public static void main(String [] args)     {	Space sp = new Space( 100, 100 ); // construct a canvas	Keyboard theKeyboard = new Keyboard();	Screen theScreen = new Screen();	// we need to keep track of the circles that we have already drawn	Vector circlesDrawn = new Vector();	// read 	for( ; ; ) {	    // read in the next circle	    double x, y, r;	    x = theKeyboard.readDouble();	    y = theKeyboard.readDouble();	    r = theKeyboard.readDouble();	    // check for the termination condition	    if( r <= 0 ) break;	// all done	    // it's a real circle	    Circle thisCircle = new Circle( r, x, y );	    // now, see if it overlaps with any of the circles already drawn	    boolean overlap = false; // no overlaps so far	    for( Iterator i = circlesDrawn.iterator(); 		 i.hasNext() && !overlap ; ) {		Circle nextCircle = (Circle) i.next();		overlap = thisCircle.overlap( nextCircle );		theScreen.println( "overlap = " + overlap + " " +				   thisCircle + " " + nextCircle );	    }	    // if the cicle doesn't overlap any of the others, draw it and 	    // add it to the set of drawn circles	    if( !overlap ) {		sp.drawCircle( x, y, r );		circlesDrawn.add( thisCircle );	    }	}	theScreen.println( "Done reading circles." );    }}