/** * Concrete strategy to compute the area of a circular shape: knows its own radius * and how to compute its area. * @author Dung X. Nguyen *

* Copyright 1999 by Dung X. Nguyen - Al rights reserved. */ public class Circle extends AShape { private double _radius; /** * Initializes this Circle with a given radius. * @param radius the radius, >= 0. * @exception IllegalArgumentException if param < 0. */ public Circle(double radius) { if (radius < 0) { throw new IllegalArgumentException ("Circle.Circle (radius): radius < 0"); } _radius = radius; } /** * @returns this Circle's area. */ public double getArea () { return Math.PI * _radius * _radius; } /** * @returns a String describing a Circle and its radius. */ public String toString () { return "Circle (radius = " + _radius + ")"; } }