More Circle
objects could be constructed in the applet,
and their draw()
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()
Although the present definition of the Circle
class is useful,
it needs more work if it is to be used as a drawing tool.