/**
* A circular shape knows its own radius and how to compute its area.
* @author Dung X. Nguyen
* @Copyright 2002 by Dung X. Nguyen - All rights reserved.
*/
public class Circle implements IShape {
private double _radius;
/**
* Initializes this Circle
with a given radius.
* @param radius the radius, >= 0.
*/
public Circle(double radius) {
_radius = radius;
}
/**
* Pie are square!
* @returns this Circle
's area.
*/
public double getArea() {
return Math.PI * _radius * _radius;
}
/**
* Overrides the inherited method from class Object.
* @returns a String describing a Circle and its radius.
*/
public String toString() {
return "Circle(radius = " + _radius + ")";
}
}