Question: (Enabling GeometricObject comparable) Modify the GeometricObject class to implement the Comparable interface, and define a static max method in the GeometricObject class for finding the

(Enabling GeometricObject comparable) Modify the GeometricObject class to implement the Comparable interface, and define a static max method in the GeometricObject class for finding the larger of two GeometricObject objects.

There needs to be a class abstract class GeometricObject1 that implements Comparable

abstract class GeometricObject1 implements Comparable {

and there needs to be a circle class that extends geometricobject

Circle.java: The circle class that extends GeometricObject class Circle1 extends GeometricObject1 {

Write a test program that uses the max method to find the larger of two circles and the larger of two rectangles.

Here is the main class:

public class Test { // Main method public static void main(String[] args) { // Create two comparable circles Circle1 circle1 = new Circle1(5); Circle1 circle2 = new Circle1(4); // Display the max circle Circle1 circle = (Circle1)GeometricObject1.max(circle1, circle2); System.out.println("The max circle's radius is " + circle.getRadius()); System.out.println(circle); } }

Thank you in advanced!

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!