Download Solution: Click to Download Solution
Solution File Name: CalculateOctagonArea.docx
Unzip Password: prestobear.com
Problem:
Write a class named Octagon that extends GeometricObject and implements
he Comparable and Cloneable inter- faces.
Assume that all eight sides of the octagon are of equal length. The area can be computed using the
following formula:
area = (2 + 4/22)* side * side
Draw the UML diagram that involves Octagon, GeometricObject, Comparable, and Cloneable.
Write a test program that creates an Octagon object with side value 5
and displays its area and perimeter. Create a new object using the clone method
and compare the two objects using the compareTo method.
1. GeometricObject.java
public abstract class GeometricObject {
}
2. Octagon.java
public class Octagon extends GeometricObject implements Comparable, Cloneable {
}
3. TestEx11.java
/**
*Write a class named Octagon that extends GeometricObject and implements
*the Comparable and Cloneable inter- faces.
*
*Assume that all eight sides of the octagon are of equal length. The area can be computed using the
*following formula:
*area = (2 + 4/22)* side * side
*
* Draw the UML diagram that involves Octagon, GeometricObject, Comparable, and Cloneable.
*Write a test program that creates an Octagon object with side value 5
*and displays its area and perimeter. Create a new object using the clone method
*and compare the two objects using the compareTo method.
*
*/
public class TestEx11 {
}