Question: Q 1 . ( Interface ) Write an interface class Comparable which has one abstract method compare ( Comparable c ) . This interface class

Q1.(Interface) Write an interface class Comparable which has one abstract method compare(Comparable c). This interface class is used to compare objects. For the homework we will only implements the interface to compare employees and circles. However, this interface can be realized to compare many types of objects. Write class Circle which has: r (radius) as a private instance variable, constructor, area(), setter and getter methods. Implement the method compare(Comparable c) which compares cs area (the parameter passed to the method) to the class area, it returns true if the class area is greater than cs area, and false otherwise Write class Employee which has: name and year as private instance variables, constructor, setter and getter methods. Implement method compare(Comparable c) which compares cs year to the class year, it returns true if the class year is greater than cs year, and false otherwise. Use the Test class provided to you to test your code. Make sure you use the same class names and instance variables names for your code to work with the test code.

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 Programming Questions!