Question: 1. Define a class Circle with a protected field radius, overloaded constructors Circle() and Circle(double radius), and getArea() that returns the area of the
1. Define a class Circle with a protected field radius, overloaded constructors Circle() and Circle(double radius), and getArea() that returns the area of the circle if the radius is larger than 0 (if the radius is equal to or less than 0, then return 0). Define another class named ComparableCircle that extends Circle. Rewrite equals method to compare the circles on the basis of area, and toString method to return "Comparable circle with radius" + radius. Write a test class TestComparableCircle to find whether the two instances of ComparableCircle objects are equal or not.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
