Question
I have a code issue. i have one program called GeometricObject1 that looks like this abstract class GeometricObject1{ protected String color; protected double weight; //
I have a code issue. i have one program called GeometricObject1 that looks like this
abstract class GeometricObject1{ protected String color; protected double weight; // Default construct protected GeometricObject1() { color = "white"; weight = 1.0; } // Construct a geometric object protected GeometricObject1(String color, double weight) { this.color = color; this.weight = weight; } // Getter method for color public String getColor() { return color; } // Setter method for color public void setColor(String color) { this.color = color; } // Getter method for weight public double getWeight() { return weight; } // Setter method for weight public void setWeight(double weight) { this.weight = weight; } //Write code here for Abstract method for area public abstract double findArea(); //Write code here Abstract method for perimeter public abstract double findPerimeter(); }
// then i have another code call Circle1 that extends GeometricObject1. i am having troubles with the two last methods of this code:
class Circle1 extends GeometricObject1 implements Comparable{ protected double radius; // Default constructor public Circle1() { this(1.0, "white", 1.0); } // Construct circle with specified radius public Circle1(double radius) { super("white", 1.0); this.radius = radius; } // Construct a circle with specified radius, weight, and color public Circle1(double radius, String color, double weight) { super(color, weight); this.radius = radius; } // Getter method for radius public double getRadius() { return radius; } // Setter method for radius public void setRadius(double radius) { this.radius = radius; } // Implement the findArea method defined in GeometricObject public double findArea() { return radius * radius * Math.PI; } // Implement the findPerimeter method defined in GeometricObject public double findPerimeter() { return 2 * radius * Math.PI; } // Override the equals() method defined in the Object class public boolean equals(Circle1 circle) { return this.radius == circle.getRadius(); } @Override // Override the toString() method defined in the Object class public String toString() { return "[Circle] radius = " + radius; } @Override // Implement the compareTo method defined in Comparable public int compareTo(Object o1) { //Need help here } public static Circle1 max(Comparable o1, Comparable o2) { //Need help here } }
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