public class BadLine { // Invariant: p1 and p2 are different points public MutablePoint p1, p2; public BadLine(MutablePoint p1, MutablePoint p2) throws IllegalArgumentException { if (!p1.equals(p2)) { this.p1 = p1; this.p2 = p2; } else { throw new IllegalArgumentException ( "Points to Line Constructor must be different: " + p1.toString() + "given twice."); } } public double slope () throws ArithmeticException { return ((p1.getY() - p2.getY()) / (p1.getX() - p2.getX())); } }