/**
 * Rect.java
 * 
 * represents a rectangle.  
 * Demonstrates how Rect objects can inherit from PointRelativeShape.
 * @author by Scot Drysdale on 4/9/00 
 */

import java.awt.*;

public class Rect extends PointRelativeShape {
  // Instance data known only to member functions
  private int myWidth, myHeight; // Rect's width and height

  /**
   *  Constructor for Rect. 
   * @param x the x coordinate of the upper left corner
   * @param y the y coordinate of the upper left corner
   * @param width the width of the rectangle
   * @param height the height of the rectangle
   * @param rectColor the color of the rectangle
   */
  public Rect(int x, int y, int width, int height, Color rectColor) {
    super(x, y, rectColor);
    myWidth = width;
    myHeight = height;
  }

  /**
   * Have the Rect object draw itself on the page passed as a parameter.
   * @page the graphics object to draw on
   */
  // Assumes that the Graphics object's color has already been set.
  protected void drawShape(Graphics page) {
    page.drawRect(getX(), getY(), myWidth, myHeight);
  }

  /**
   * @return the area of the rectangle
   */
  public double areaOf() {
    return myWidth * myHeight;
  }
}