Question: 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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!