Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

Do your points support the goal?

Answered: 1 week ago

Question

3. Who would the members be?

Answered: 1 week ago