Pentagon Shape
Create and complete the implementation of the Pentagon
class.
Your class should be public, inherit from the Shape
class, and provide the following methods:
- Constructor that takes a
double
parameter. Creates a newPentagon
with the passed side length. If the passed length is less than or equal to 0, throw anIllegalArgumentException
. You should call theShape
constructor and pass it theString
"pentagon" to identify the type of this shape. - Public instance method
area
that takes no arguments and returns adouble
. 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 useMath.sqrt
to solve this problem. - Override
public boolean equals(Object other)
. Returntrue
ifother
is aPentagon
with the same side length, andfalse
otherwise. Note thatother
may benull
or not aPentagon
.
Finally, note that your class should not expose any of its internal state publicly.