// This appears in Core Web Programming from
// Prentice Hall Publishers, and may be freely used
// or adapted. 1997 Marty Hall, hall@apl.jhu.edu.

/** A rectangle implements the getArea method.
 *  This satisfies the Measurable interface, so
 *  rectangles can be instantiated.
 */

public class Rectangle extends Polygon {
  private double width, height;
  
  public Rectangle(int x, int y, 
                   double width, double height) {
    setNumSides(2);
    setX(x);
    setY(y);
    setWidth(width);
    setHeight(height);
  }

  public double getWidth() {
    return(width);
  }

  public void setWidth(double width) {
    this.width = width;
  }

  public double getHeight() {
    return(height);
  }

  public void setHeight(double height) {
    this.height = height;
  }

  /** Required to implement Measurable interface. */

  public double getArea() {
    return(width * height);
  }
}

