public Circle( int x, int y, int radius ) { this.x = x; this.y = y; this.radius = radius; }
There must be a drawing method.
The draw()
drawOval(int x, int Y, int width, int height)
The method must be told on which drawing area to draw a circle, so the draw method has a single parameter for the Graphics object of the applet.
class Circle { // variables int x, y, radius; // constructors public Circle() { x = 0; y = 0; radius = 0; } public Circle( int x, int y, int radius ) { this.x = x; this.y = y; this.radius = radius; } // methods draw( Graphics gr ) { int ulX = _________________________ ; // X of upper left corner of rectangle int ulY = _________________________ ; // Y of upper left corner of rectangle gr.drawOval( ulX, ulY, _________________, _________________ ); } }
If you know the center of the circle, (x, y) and radius, you can calculate the coordinates of the upperleft corner of the square that contains the circle, and its width and height. Here is a picture to help: