Class Rectangle
java.lang.Object
Rectangle
This class represents a Rectangle.
There are two new fields:
private double height
private double width
- Author:
- Bob Myers myers@cs.fsu.edu
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubledefine constant for default heightstatic final doubledefine constant for default widthprivate doubleheight of the rectanglestatic final doubledefine constant for shortest heightstatic final doubledefine constant for shortest widthprivate doublewidth of the rectangle -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublearea()The area of this object.doubleThis object height value.doublegetWidth()This object width value.doubleThe perimeter of this object.private voidprivateSetHeight(double h) Set this object's height value.private voidprivateSetWidth(double w) Set this object's width value.voidsetHeight(double height) Set this object height value.voidEmpty set.voidsetRectangle(double height, double width) Complete set.voidsetRectangle(Rectangle rectangle) Copy set.voidsetWidth(double width) Set this object width value.toString()A String representation of this object.
-
Field Details
-
SHORTEST_HEIGHT
define constant for shortest height- See Also:
-
SHORTEST_WIDTH
define constant for shortest width- See Also:
-
DEFAULT_HEIGHT
define constant for default height- See Also:
-
DEFAULT_WIDTH
define constant for default width- See Also:
-
height
height of the rectangle -
width
width of the rectangle
-
-
Constructor Details
-
Rectangle
Complete constructor.- Parameters:
height- the requested heightwidth- the requested width
-
Rectangle
public Rectangle()Empty constructor.heightandwidthset toDEFAULT_HEIGHTandDEFAULT_WIDTHrespectivly -
Rectangle
Copy constructor.- Parameters:
rectangle- this object will haveheightandwidthset to copy of incoming rectangle
-
-
Method Details
-
privateSetHeight
Set this object's height value.- Parameters:
h- set this object height value to the parameter, with a minimum size ofSHORTEST_HEIGHT
-
privateSetWidth
Set this object's width value.- Parameters:
w- set this object width value to the parameter, with a minimum size ofSHORTEST_WIDTH
-
getHeight
This object height value.- Returns:
- this object height value
-
getWidth
This object width value.- Returns:
- this object width value
-
setHeight
Set this object height value.- Parameters:
height- set this object height value to the parameter
-
setWidth
Set this object width value.- Parameters:
width- set this object width value to the parameter
-
setRectangle
Complete set.- Parameters:
height- heightwidth- width
-
setRectangle
Empty set.heightandwidthset toDEFAULT_HEIGHTandDEFAULT_WIDTHrespectivly -
setRectangle
Copy set.- Parameters:
rectangle- this object will haveheightandwidthset to copy of incoming rectangle data
-
area
The area of this object.- Returns:
- the area of this object
-
perimeter
The perimeter of this object.- Returns:
- the perimeter of this object
-
toString
A String representation of this object.
-