public static void main(String[] args) { Point p = new Point(1, 1); Point q = new Point(1, 1); Point r = new Point(1, 3); int restult = p.SLOPE_ORDER.compare(q, r); // compareTo(q); System.out.printf("%s\n", Double.toString(p.slopeTo(q))); int restult2 = p.SLOPE_ORDER.compare(r, q); // compareTo(q); System.out.printf("%s\n", Double.toString(p.slopeTo(r))); }
private static void testSlopeCompare() { Point p; Point q; Point r; p = new Point(14018, 23647); q = new Point(14018, 7929); r = new Point(28872, 18319); assert p.SLOPE_ORDER.compare(q, r) == 1; p = new Point(400, 148); q = new Point(177, 141); r = new Point(409, 309); assert p.SLOPE_ORDER.compare(q, r) == -1; p = new Point(1, 0); q = new Point(1, 0); r = new Point(9, 2); assert p.SLOPE_ORDER.compare(q, r) == -1; }
// unit test public static void main(String[] args) { /* YOUR CODE HERE */ Point p, q, r; p = new Point(87, 479); q = new Point(87, 479); assert p.slopeTo(q) == Double.NEGATIVE_INFINITY; p = new Point(25681, 22210); q = new Point(25681, 22210); assert p.slopeTo(q) == Double.NEGATIVE_INFINITY; p = new Point(3, 4); q = new Point(3, 4); assert p.slopeTo(q) == Double.NEGATIVE_INFINITY; p = new Point(8, 5); q = new Point(9, 4); r = new Point(8, 5); assert p.SLOPE_ORDER.compare(q, r) == 1; assert p.slopeTo(q) == -1.0; assert p.slopeTo(r) == Double.NEGATIVE_INFINITY; }