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
Modifier and TypeFieldDescriptionstatic final double
define constant for default heightstatic final double
define constant for default widthprivate double
height of the rectanglestatic final double
define constant for shortest heightstatic final double
define constant for shortest widthprivate double
width of the rectangle -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
area()
The area of this object.double
This object height value.double
getWidth()
This object width value.double
The perimeter of this object.private void
privateSetHeight
(double h) Set this object's height value.private void
privateSetWidth
(double w) Set this object's width value.void
setHeight
(double height) Set this object height value.void
Empty set.void
setRectangle
(double height, double width) Complete set.void
setRectangle
(Rectangle rectangle) Copy set.void
setWidth
(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.height
andwidth
set toDEFAULT_HEIGHT
andDEFAULT_WIDTH
respectivly -
Rectangle
Copy constructor.- Parameters:
rectangle
- this object will haveheight
andwidth
set 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.height
andwidth
set toDEFAULT_HEIGHT
andDEFAULT_WIDTH
respectivly -
setRectangle
Copy set.- Parameters:
rectangle
- this object will haveheight
andwidth
set 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.
-