Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem: Compare areas of different geometric shapes (filename: CompareShapeAreas.java) Define a class named ComparableCircle that extends the Circle class and implements the Comparable interface as
Problem: Compare areas of different geometric shapes (filename: CompareShapeAreas.java) Define a class named ComparableCircle that extends the Circle class and implements the Comparable interface as shown below. The Circle class itself extends the GeometricObject class class ComparableCircle extends Circle implements Comparable Implement the CompareTo method defined inside the Comparable interface to compare the areas between a Circle object and a GeometricObject object. It returns 1 if the circle has a larger area, else if the circle has a smaller area, it returns -1, else it returns 0 For implementing the Geometric class and the Circle class, you may use the code from the book or the slides Similarly, based on the code from the book or the slides, define a class named ComparableRectangle that extends the Rectangle class and implements the Comparable interface. The Rectangle class itself extends the GeometricObject class. Implement the CompareTo method defined inside the Comparable interface to compare the areas between a Rectangle object and a GeometricObject object. It returns 1 if the rectangle has a larger area, else if the rectangle has a smaller area, it returns -1, else it returns 0 Write a test class to find the larger of two instances of ComparableCircle objects by invoking the CompareTo method, and the larger between an instance of a ComparableCircle and an instance of ComparableRectangle also by invoking the CompareTo method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started