Class Rectangle
java.lang.Object
Rectangle
This class represents a Rectangle.
There are two new fields:
private double height
private double width
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
define constant for default heightstatic final double
define constant for default widthstatic final double
define constant for shortest heightstatic final double
define constant for shortest width -
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.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
public static final double SHORTEST_HEIGHTdefine constant for shortest height- See Also:
-
SHORTEST_WIDTH
public static final double SHORTEST_WIDTHdefine constant for shortest width- See Also:
-
DEFAULT_HEIGHT
public static final double DEFAULT_HEIGHTdefine constant for default height- See Also:
-
DEFAULT_WIDTH
public static final double DEFAULT_WIDTHdefine constant for default width- See Also:
-
-
Constructor Details
-
Rectangle
public Rectangle(double height, double width) 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
-
getHeight
public double getHeight()This object height value.- Returns:
- this object height value
-
getWidth
public double getWidth()This object width value.- Returns:
- this object width value
-
setHeight
public void setHeight(double height) Set this object height value.- Parameters:
height
- set this object height value to the parameter
-
setWidth
public void setWidth(double width) Set this object width value.- Parameters:
width
- set this object width value to the parameter
-
setRectangle
public void setRectangle(double height, double width) Complete set.- Parameters:
height
- heightwidth
- width
-
setRectangle
public void 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
public double area()The area of this object.- Returns:
- the area of this object
-
perimeter
public double perimeter()The perimeter of this object.- Returns:
- the perimeter of this object
-
toString
A String representation of this object.
-