More Circle
objects could be constructed in the applet,
and their draw()
methods called.
Circle
ObjectsThe suggested answer is one way to do it. (Another way will be used in a few pages.) Here is the applet, modified to draw three concentric circles:
// assume that the drawing area is 200 by 200 public class testCircle3 extends Applet { Circle circ1 = new Circle( 100, 100, 10 ); Circle circ2 = new Circle( 100, 100, 20 ); Circle circ3 = new Circle( 100, 100, 30 ); public void paint ( Graphics gr ) { circ1.draw( gr ); circ2.draw( gr ); circ3.draw( gr ); } }
Here is what it draws:
Notice that with the Circle
object
it was much easier to draw concentric
circles than using drawOval()
directly.
Although the present definition of the Circle
class is useful,
it would be even more useful if just one Circle
object could be used
to draw several circles at different locations.