I'm having trouble with this one, while the code is really long I'll present a basic view of the hierarchy of all my classes.
Interface:
public interface Shape extends Comparable<Shape> {
Abstract class:
public abstract class AbstractShape implements Shape {
...
public int compareTo(Shape theOther) {
//code already written
public int compare(Shape s1, Shape s2) {
//code already written
Circle class
public class Circle extends AbstractShape {
Rectangle class
public class Rectangle extends AbstractShape {
And finally.. the driver class
public class project {
...
Collections.sort(theList, ???);
After creating a List of all the shapes I have in mind, I would like to sort them using the Collections.sort method. I know how to use simple operations of the Collections.sort method, but how exactly would I specify the statement above to use the specified comparator that's sitting in the abstract class? I thought about changing the hierarchy around but I'm restricted to this hierarchy set up as my instructor does not allow us to modify the method headers at all for this assignment.
Any help is greatly appreciated!