/** * @requires name != null && p1 != null && p2 != null * @effects constructs a new GeoSegment with the specified name and endpoints */ public GeoSegment(String name, GeoPoint p1, GeoPoint p2) { if (name == null || p1 == null || p2 == null) { throw new IllegalArgumentException("Input must not be null"); } this.name = name; this.p1 = p1; this.p2 = p2; length = p1.distanceTo(p2); heading = p1.headingTo(p2); hash = (p1.hashCode() * 73 + p2.hashCode() * 137) % 7134653 * (name.hashCode() + 1) + 1; checkRep(); }