Question: Design and modify the GeometricObject class (GeometricObject.java) to implement the Comparable interface. Make sure to use the GeometricObject.java file from sample codes. The modified GeometricObject

 Design and modify the GeometricObject class (GeometricObject.java) to implement the Comparable

Design and modify the GeometricObject class (GeometricObject.java) to implement the Comparable interface. Make sure to use the GeometricObject.java file from sample codes. The modified GeometricObject class must implement the Comparable interface with the following features: Implement the compareTo method. This method must compare the area of this object to the area of the given object. If this object's area is greater than the given object's area, it returns 1. If this object's area is smaller than the given object 's area, it retums -1. o If this object's area is equal to the given object's area, it returns 0. Define a static method called max for finding the larger of two given GeometricObject instances. public static GeometricObject max(GeometricObject ol, Geometric Object 02) You need to call the compare To method in the max method. If both the GeometricObject instances are equal, it returns the first given GeometricObject instance. Write a testing Java application (GeometricObjectTest.java) such that: Creates two Circle objects called circlel (radius=5) and circle2 (radius=4) Creates two Rectangle objects called rectanglel (width=5 and height = 4) and rectangle2 (width= 4 and height=5) Use the max method to find the larger of two circles and display its radius. Use the max method to find the larger of two rectangles and display its width and height Use the max method to find the larger of (circlel, rectanglel) and display its fields (either radius or width/height). Note: You MUST NOT change the Circle and Rectangle class in the sample codes

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!