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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started