/** * A rectangular shape knows its width and height and how to compute its area. * @author Dung X. Nguyen ** Copyright 2001 by Dung X. Nguyen - All rights reserved. *
*/ public class Rectangle extends AShape { private double _width; private double _height; /** * Initializes thisRectangle
width a given width and a given height * @param w width of thisRectangle
, >= 0. * @param h height of thisRectangle
, >= 0. */ public Rectangle(double w, double h) { _height = h; _width = w; } /** * @returns thisRectangle
's area. */ public double getArea() { return _height * _width; } /** * Overrides the inherited method from class Object. * @returns a String describing a Rectangle with its width and height. */ public String toString() { return "Rectangle (h = " + _height + ", w = " + _width + ")"; } }