Class Rectangle

java.lang.Object
  extended by Rectangle

public class Rectangle
extends java.lang.Object

A class that manages a rectangle given the length and width.


Field Summary
private  double length
           
private  double width
           
 
Constructor Summary
Rectangle()
          Create a new rectangle object with length and width = 1.0
Rectangle(double rLength, double rWidth)
          Create a new rectangle object given the length and width of the rectangle.
 
Method Summary
 double getArea()
          Return the area of the rectangle.
 double getLength()
          Return the length of the rectangle.
 double getPerimeter()
          Return the perimeter of the rectangle.
 double getWidth()
          Return the width of the rectangle.
 void setLength(double newLength)
          Change the length of the rectangle to the new length given
 void setWidth(double newWidth)
          Change the width of the rectangle to the new width given
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

length

private double length

width

private double width
Constructor Detail

Rectangle

public Rectangle()
Create a new rectangle object with length and width = 1.0


Rectangle

public Rectangle(double rLength,
                 double rWidth)
Create a new rectangle object given the length and width of the rectangle.

Parameters:
rLength - length of the rectangle. Must be greater than 0.
rWidth - width of the rectangle. Must be greater than 0.
Method Detail

getLength

public double getLength()
Return the length of the rectangle.

Returns:
the length of the rectangle.

getWidth

public double getWidth()
Return the width of the rectangle.

Returns:
the width of the rectangle.

getPerimeter

public double getPerimeter()
Return the perimeter of the rectangle.

Returns:
the perimeter of the rectangle.

getArea

public double getArea()
Return the area of the rectangle.

Returns:
the area of the rectangle.

setLength

public void setLength(double newLength)
Change the length of the rectangle to the new length given

Parameters:
newLength - length of the rectangle. Must be greater than 0

setWidth

public void setWidth(double newWidth)
Change the width of the rectangle to the new width given

Parameters:
newWidth - width of the rectangle. Must be greater than 0