//package chapter8; /** * Title: Chapter 8, "Class Inheritance and Interfaces" * Description: Examples for Chapter 8 * Copyright: Copyright (c) 2000 * Company: Armstrong Atlantic State University * @author Y. Daniel Liang * @version 1.0 */ // Circle.java: The circle class that extends GeometricObject public class Circle extends GeometricObject { private double radius; /**Default constructor*/ public Circle() { this(1.0); } /**Construct circle with a specified radius*/ public Circle(double rad) { this(rad, "white", false); } /**Construct a circle with specified radius, filled, and color*/ public Circle(double rad, String c, boolean fill) { super(c, fill); radius = rad; } /**Return radius*/ public double getRadius() { return radius; } /**Set a new radius*/ public void setRadius(double rad) { radius = rad; } /**Implement the findArea method defined in GeometricObject*/ public double findArea() { return radius*radius*Math.PI; } /**Implement the findPerimeter method defined in GeometricObject*/ public double findPerimeter() { return 2*radius*Math.PI; } /**Override the equals() method defined in the Object class*/ public boolean equals(Circle circle) { return this.radius == circle.getRadius(); } /**Override the toString() method defined in the Object class*/ public String toString() { return "[Circle] radius = " + radius; } }