Pentagon Shape
Geoffrey Challen // 2021.10.0
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
doubleparameter. Creates a newPentagonwith the passed side length. If the passed length is less than or equal to 0, throw anIllegalArgumentException. You should call theShapeconstructor and pass it theString"pentagon" to identify the type of this shape. - Public instance method
areathat 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.sqrtto solve this problem. - Override
public boolean equals(Object other). Returntrueifotheris aPentagonwith the same side length, andfalseotherwise. Note thatothermay benullor not aPentagon.
Finally, note that your class should not expose any of its internal state publicly.