Point implements Comparable<Point> { @Override public int compareTo(Point point) { if (this.y < point.y) { return -1; } else if ((int) this.y == (int) point.y) { if (this.x < point.x) { return -1; } else if ((int) this.x == (int) point.x) { return 0; } else { return 1; } } else { return 1; } } Point(double x, double y);  Point(Point point);  Point(String point); double getX(); double getY(); double distance(Point point); void moveToward(Point point, double distance); void pathToward(Point destination, double distance); boolean nextStep(Point point, double distance); @Override String toString(); String toNeatString(); @Override boolean equals(Object object); boolean lazyEquals(Object object); @Override int hashCode(); @Override int compareTo(Point point);  }
@Test public void testCompareTo() { Point point = new Point(3, 3); Point north = new Point(3, 1); Point south = new Point(3, 5); Point east = new Point(5, 3); Point west = new Point(1, 3); Point northwest = new Point(1, 1); Point northeast = new Point(5, 1); Point southwest = new Point(1, 5); Point southeast = new Point(5, 5); Assert.assertEquals("Comparison error ().", 0, point.compareTo(point)); Assert.assertEquals("Comparison error (N).", 1, point.compareTo(north)); Assert.assertEquals("Comparison error (S).", -1, point.compareTo(south)); Assert.assertEquals("Comparison error (E).", -1, point.compareTo(east)); Assert.assertEquals("Comparison error (W).", 1, point.compareTo(west)); Assert.assertEquals("Comparison error (NW).", 1, point.compareTo(northwest)); Assert.assertEquals("Comparison error (NE).", 1, point.compareTo(northeast)); Assert.assertEquals("Comparison error (SW).", -1, point.compareTo(southwest)); Assert.assertEquals("Comparison error (SE).", -1, point.compareTo(southeast)); }