10 date 2008.03.26.17.45.30; author rmh3093; state Exp;
15 date 2007.08.16.19.10.01; author vcss232; state Exp;
33 * $Id: Circle.java,v 1.1 2007/08/16 19:10:01 vcss232 Exp rmh3093 $
36 * $Log: Circle.java,v $
37 * Revision 1.1 2007/08/16 19:10:01 vcss232
45 * Class that implements a Circle.
47 * @@author Paul Tymann
48 * @@author Paul Tymann
52 public class Circle extends Shape {
54 private double radius; // the radius of the circle
57 * Create a new circle.
59 * @@param myXPos x location for center of the circle
60 * @@param myYPos y location for center of the circle
61 * @@param myRadius radius of the circle
63 * @@exception ShapeException Exception is thrown when the radius is
64 * a negative value. "Negative radius in
68 public Circle( double myXPos, double myYPos, double myRadius )
69 throws ShapeException {
70 super( myXPos, myYPos );
73 throw new ShapeException("Negative radius in Circle constructor");
81 * Return the radius of the circle.
83 * @@return radius of the circle
86 public double getRadius() {
91 * Compute and return the area of the circle.
93 * @@return the area of the circle
96 public double area() {
97 return Math.PI * radius * radius;
101 * Stretches the size of the circle by multiplying
102 * the radius by the factor provided.
104 * @@param factor factor to stretch by
106 * @@exception ShapeException Exception is thrown when a negative
107 * factor parameter is received.
108 * "Negative factor in call to stretchBy"
111 public void stretchBy( double factor ) throws ShapeException {
114 throw new ShapeException("Negative factor in call to stretchBy");
116 radius = radius * factor;
122 * Return a string representation of a circle.
124 * @@return a string representing this circle
127 public String toString() {
149 private double radius; // the radius of the circle
152 * Create a new circle.
154 * @@param myXPos x location for center of the circle
155 * @@param myYPos y location for center of the circle
156 * @@param myRadius radius of the circle
158 * @@exception ShapeException Exception is thrown when the radius is
159 * a negative value. "Negative radius in
160 * Circle constructor"
163 public Circle( double myXPos, double myYPos, double myRadius )
164 throws ShapeException {
165 super( myXPos, myYPos );
171 * Return the radius of the circle.
173 * @@return radius of the circle
176 public double getRadius() {
181 * Compute and return the area of the circle.
183 * @@return the area of the circle
186 public double area() {
187 return Math.PI * radius * radius;
191 * Stretches the size of the circle by multiplying
192 * the radius by the factor provided.
194 * @@param factor factor to stretch by
196 * @@exception ShapeException Exception is thrown when a negative
197 * factor parameter is received.
198 * "Negative factor in call to stretchBy"
201 public void stretchBy( double factor ) throws ShapeException {
202 radius = radius * factor;
206 * Return a string representation of a circle.
208 * @@return a string representing this circle
211 public String toString() {