public class BadLineTwo { // Invariant: p1 and p2 are different points private MutablePoint p1, p2; public BadLineTwo(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 MutablePoint getP1() { return p1; } public MutablePoint getP2() { return p2; } public double slope () throws ArithmeticException { return ((p1.getY() - p2.getY()) / (p1.getX() - p2.getX())); } }