/**
 *  Circle.java
 *
 * Shows how a Circle class can be built by inheritance.
 * Note that this class implements scale() as well as the methods in GeomShape.
 * @author Scot Drysdale on 4/27/00.
 */

import java.awt.*;

public class Circle extends PointRelativeShape {
  private int myRadius; // Circle radius

  /**
   * Constructor for Circle. Called to create a circle object with center
   * (x, y), radius r, and color circleColor.
   * @param x the x coordinate of the center
   * @param y the y coordinate of the center
   * @param r the radius
   * @param circleColor the circle's color
   */
  // 
  public Circle(int x, int y, int r, Color circleColor) {
    super(x, y, circleColor);
    myRadius = r;
  }

  /**
   * Have the Circle object draw itself on the page passed as a parameter.
   * Assumes that the Graphics object's color has already been set.
   */
  protected void drawShape(Graphics page) {
    page.drawOval(getX() - myRadius, getY() - myRadius, 2 * myRadius,
        2 * myRadius);
  }

  /**
   *  Have the Circle change its radius by the scaling 
   * @param factor the scaling factor
   */
  public void scale(double factor) {
    myRadius = (int) (factor * myRadius);
  }

  /**
   * Have the Circle object return its area.
   */
  public double areaOf() {
    return Math.PI * myRadius * myRadius;
  }
}