13.11 Write 2-3 paragraphs in which you compare and contrast a design where Octa
ID: 3831867 • Letter: 1
Question
13.11 Write 2-3 paragraphs in which you compare and contrast a design where Octagon extends GeometricObject and implements Comparable with one in which there is no GeometricObject parent class and no Comparable interface incorporated. What are the advantages and disadvantages of both designs?
[JAVA] (Do not need the program, just the written paragraphs)
13. II (The octagon class) 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/ 2)* side side Draw the UML diagram that involves Octagon Geometricobject, Comparable. and Coneable. 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 methodExplanation / Answer
GeometricObject class: It is a abstract class that can holds the all comoon fields and methods that any type of geometric object can have. SO by this we can reduce redundancy because these common property will be inherited when a class extends this GeometricObject class.
If we do not extend this class then we need to write same common method and variables in each of the class.
Also, by extending GeometricObject class, we can achieve Polymorphism because if all geometric objects extends this GeometricObject class then we can hold object of any geometric type by using GeometricObject reference.
So, we can reduce redundancy and can acheve Polymorphism.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.