/**
* A rectangular shape knows its width and height and how to compute its area.
* @author Dung X. Nguyen
* @Copyright 2002 by Dung X. Nguyen - All rights reserved.
*/
public class Rectangle implements IShape {
private double _width;
private double _height;
/**
* Initializes this Rectangle
width a given width and a given height
* @param w width of this Rectangle
, >= 0.
* @param h height of this Rectangle
, >= 0.
*/
public Rectangle(double w, double h) {
_height = h;
_width = w;
}
/**
* @returns this Rectangle
'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 + ")";
}
}