Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

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

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions