/* **************************************************************************** * Kelli Wiseth * kelli@alameda-tech-lab.com * CIS 255AX * Program name: MyCircle.java * Program Description: The subclass that inherits from MyLine to create * a circle shape. Only one of the points from MyLine is used; the MyCircle * class also takes a radiusValue that is used with one of the points to * draw the circle. * * Assignment #4 * 29 March 2005 **************************************************************************** */ import java.awt.*; public class MyCircle extends MyLine { private double radius, width, height; //the default constructor (with no args that sets all coordinates to 0) public MyCircle(){ super(0,0,0,0); setRadius(0); } public MyCircle(int x1, int y1, double radiusValue){ super(x1, y1, 0, 0); setRadius(radiusValue); } public double getRadius(){ return radius; } //Radius must be a non-negative value public void setRadius(double radiusValue){ radius = (radiusValue < 0.0 ? 0.0 : radiusValue); } /************************************************************************* * Draw method that overrides the draw method in MyLine. * To draw the circles we take the coordinates of one of the point objects * inherited from MyLine (and instantiated in the constructor) and multiply * the radiusValue x 2 (twice. ************************************************************************** */ public void draw( Graphics g){ g.drawOval(getBeginPointX(), getBeginPointY(), (int)(getRadius()*2), (int)(getRadius()*2)); } } // MyCircle