public class BadLineThree { // Invariant: p1 and p2 are different points private final Point[] points = new Point[2]; public BadLineThree(Point p1, Point p2) throws IllegalArgumentException { if (!p1.equals(p2)) { points[0] = p1; points[1] = p2; } else { throw new IllegalArgumentException ( "Points to Line Constructor must be different: " + p1.toString() + "given twice."); } } public Point[] getPoints() { return points; } public double slope () throws ArithmeticException { return ((points[0].getY() - points[1].getY()) / (points[0].getX() - points[1].getX())); } }