// Fig. 7.5: Circle.java // Definition of class Circle public class Circle extends Point { // inherits from Point protected double radius; // no-argument constructor public Circle() { // implicit call to superclass constructor here setRadius( 0 ); System.out.println( "Circle constructor: " + toString() ); } // Constructor public Circle( double r, int a, int b ) { super( a, b ); // call the superclass constructor setRadius( r ); System.out.println( "Circle constructor: " + toString() ); } // finalizer protected void finalize() throws Throwable { System.out.println( "Circle finalizer: " + toString() ); super.finalize(); // call superclass finalize method } // Set radius of Circle public void setRadius( double r ) { radius = ( r >= 0 ? r : 0 ); } // Get radius of Circle public double getRadius() { return radius; } // Calculate area of Circle public double area() { return Math.PI * radius * radius; } // convert the Circle to a String public String toString() { return "Center = " + super.toString() + "; Radius = " + radius; } }