So I'm trying to compare two shape's area using Comparable. I implement it in my class and I'm trying to override compare right now in my LineSegment class which extends my own abstract class Shape.
class LineSegment extends Shape implements Comparable{
public int compareTo(Object object1, Object object2)
{
LineSegment ls1 = (LineSegment) object1;
LineSegment ls2 = this;
return Double.compare(ls1.getArea(), ls2.getArea());
}
}
Before I had an issue with comparing two doubles and I saw a solution to the problem on here with that return statement and Double. getArea() returns a double area for the LineSegment. So I have ran into this error, any help would be appreciated, thanks- LineSegment is not abstract and does not override abstract method compareTo(java.lang.Object) in java.lang.Comparable
class LineSegment extends Shape implements Comparable