Create and complete the implementation of the Pentagon
class.
Your class should be public, inherit from the Shape
class, and provide the following methods:
double
parameter.
Creates a new Pentagon
with the passed side length.
If the passed length is less than or equal to 0, throw an IllegalArgumentException
.
You should call the Shape
constructor and pass it the String
"pentagon" to identify the type of this
shape.area
that takes no arguments and returns a double
.
Return the area of this shape, given only the side length, which you can find here:
https://www.cuemath.com/measurement/area-of-pentagon/.
You will need to use Math.sqrt
to solve this problem.public boolean equals(Object other)
.
Return true
if other
is a Pentagon
with the same side length, and false
otherwise.
Note that other
may be null
or not a Pentagon
.Finally, note that your class should not expose any of its internal state publicly.
Stuck? You may find these lessons helpful: