[Class: Java] [*** The picture below is for reference only, do not post any code
ID: 3834036 • Letter: #
Question
[Class: Java]
[***The picture below is for reference only, do not post any code.***]
Here is the actual question...
13.10 Write 2-3 paragraphs explaining the design rationale for making Rectangle extend Geometric Object and implement the Comparable interface. How is making Rectangle a child class of GeometricObject and one that implements Comparable interface a better idea than the alternative of not doing these things, from a design perspective?
13.10 (Enable Rectangle comparable) Rewrite the Rectangle class in Listing 13.3 to extend Geometricobject and implement the Comparable interface. Override the equals method in the object class. Two Rectangle objects are equal if their areas are the same. Draw the UML diagram that involves Rectangle, Geometricobject, and ComparableExplanation / Answer
1) design rationale for making Rectangle extend Geometric Object and implement the Comparable interface.
if you are making Reactangle class that extends Geometric Object and implement Comparable interface than you have to override compareTo methode of the interface
but the better idea is to make Geometric Class extends Comparable interface and rectangle class extends the Geometric Class
it has following benefits
--> as you are making rectangle class child class and Geometric class that implements comparable interface you have to compulsary override compareTo method()
-> and the other benefit is that if the other geometric object wants to extend that class then if this Geometric Class is implementing the Comparable interface the other Geometric Object like triangle circle will get benefit of that design
it is generalized then
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.