P
Paul Morrison
Hi,
I have written an Edge class that takes two Point values as parameters and I
want to make the class implement comparable but I dont know how to do it.
This is what I have got so far:
public class Edge implements Comparable<Edge> {
Point point1;
Point point2;
double ymin, ymax, xvalue, oneoverm;
Edge(Point point1, Point point2) {
this.point1 = point1;
this.point2 = point2;
.......
public Edge compareTo(Edge e) {
//to do
}
I want to sort the edges in order of their ymin values, would I be correct
in thinking that I do something along the lines of:
if (edge.ymin < e.ymin)
return edge;
else
return e;
Is this on the right lines?
Cheers
Paul
I have written an Edge class that takes two Point values as parameters and I
want to make the class implement comparable but I dont know how to do it.
This is what I have got so far:
public class Edge implements Comparable<Edge> {
Point point1;
Point point2;
double ymin, ymax, xvalue, oneoverm;
Edge(Point point1, Point point2) {
this.point1 = point1;
this.point2 = point2;
.......
public Edge compareTo(Edge e) {
//to do
}
I want to sort the edges in order of their ymin values, would I be correct
in thinking that I do something along the lines of:
if (edge.ymin < e.ymin)
return edge;
else
return e;
Is this on the right lines?
Cheers
Paul