@Test public void compareToTest() { Point point1 = new Point(X, Y); Point point2 = new Point(X, Y); Point point3 = new Point(0, 0); Assert.assertEquals(0, point1.compareTo(point2)); Assert.assertNotEquals(0, point1.compareTo(point3)); Assert.assertNotEquals(0, point3.compareTo(point1)); }
@Override public int compareTo(Point point) { if (this.x > point.x) { return 1; } else if (this.x < point.x) { return -1; } else if (this.y > point.y) { return 1; } else if (this.y < point.y) { return -1; } return 0; }
Point implements Comparable<Point>, Serializable { @Override public int compareTo(Point point) { if (this.x > point.x) { return 1; } else if (this.x < point.x) { return -1; } else if (this.y > point.y) { return 1; } else if (this.y < point.y) { return -1; } return 0; } }
Point implements Comparable<Point>, Serializable { @Override public int compareTo(Point point) { if (this.x > point.x) { return 1; } else if (this.x < point.x) { return -1; } else if (this.y > point.y) { return 1; } else if (this.y < point.y) { return -1; } return 0; } Point(double x, double y); }
Point implements Comparable<Point>, Serializable { @Override public int compareTo(Point point) { if (this.x > point.x) { return 1; } else if (this.x < point.x) { return -1; } else if (this.y > point.y) { return 1; } else if (this.y < point.y) { return -1; } return 0; } Point(double x, double y); @Override int compareTo(Point point); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
Point implements Comparable<Point>, Serializable { @Override public int compareTo(Point point) { if (this.x > point.x) { return 1; } else if (this.x < point.x) { return -1; } else if (this.y > point.y) { return 1; } else if (this.y < point.y) { return -1; } return 0; } Point(double x, double y); @Override int compareTo(Point point); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); final double x; final double y; }