Rectangle.java
package com.bozoid.cis370.hw02;
/**
A simple <code>Rectangle</code> class for homework #2.
@author Walt Leipold
*/
public class Rectangle extends Shape
{
/**
Construct a <code>Rectangle</code> object.
@param x x-coordinate of one corner
@param y y-coordinate of one corner
@param w width of <code>Rectangle</code>
@param h height of <code>Rectangle</code>
*/
public Rectangle(double x,double y,double w,double h)
{
// Call the superclass constructor *first* (required by
// the language), then fix up the location afterwards.
super(x,y);
this.width = w;
this.height = h;
}
/**
@return the width of this <code>Rectangle</code>
*/
public double getWidth()
{
return width;
}
/**
@return the height of this <code>Rectangle</code>
*/
public double getHeight()
{
return height;
}
/**
@return a <code>String</code> describing this <code>Line</code>
*/
public String toString()
{
return getClass().getName() + "[" +
"x=" + formatNum(getX()) + "," +
"y=" + formatNum(getY()) + "," +
"w=" + formatNum(width) + "," +
"h=" + formatNum(height) + "]";
}
private double width,height;
}