IN JAVA Write a class named Octagon that extends GeometricObject and implements
ID: 3837306 • Letter: I
Question
IN JAVA
Write a class named Octagon that extends GeometricObject and implements the Comparable and Cloneable interfaces. Assume that all eight sides of the octagon are of equal size.The area can be computed using the following formula:
area = (2 + 4 / sqrt(2)) * side * side
For the purpose of this exercise, two octagons are equal if their areas are equal. Please write the complete class for Octagon including the property(s), the constructor(s) and methods. Remember to implement all the required methods for the Comparable and Cloneable interfaces.
Explanation / Answer
GeometricObject program:
Octagon program
s
note:
Comparable and Clonable are interfaces. This means that by saying a class supports an interface it is declaring that it will have a particular set of functions defined and that code that uses the object can depend on those methods to exist.