@Test public void equalsTest() { Point point1 = new Point(1, 2); Point point2 = new Point(1, 2); Point point3 = new Point(1, 1); LineSegment point1ToPoint2 = new LineSegment(point1, point2); LineSegment point1ToPoint3 = new LineSegment(point1, point3); LineSegment point1ToPoint1 = new LineSegment(point1, point1); Assert.assertNotEquals(point1ToPoint1, point1ToPoint3); Assert.assertEquals(point1ToPoint1, point1ToPoint1); Assert.assertEquals(point1ToPoint1, point1ToPoint2); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof LineSegment)) { return false; } LineSegment other = (LineSegment) obj; if (other.start.equals(this.start) && other.end.equals(this.end)) { return true; } return false; }
LineSegment { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof LineSegment)) { return false; } LineSegment other = (LineSegment) obj; if (other.start.equals(this.start) && other.end.equals(this.end)) { return true; } return false; } }
LineSegment { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof LineSegment)) { return false; } LineSegment other = (LineSegment) obj; if (other.start.equals(this.start) && other.end.equals(this.end)) { return true; } return false; } LineSegment(Point start, Point end);  LineSegment(Point start, Point direction, double distance); }
LineSegment { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof LineSegment)) { return false; } LineSegment other = (LineSegment) obj; if (other.start.equals(this.start) && other.end.equals(this.end)) { return true; } return false; } LineSegment(Point start, Point end);  LineSegment(Point start, Point direction, double distance); double angleTo(LineSegment other); LineSegment clipToRectangle(Rectangle r); @Override boolean equals(Object obj); @Override int hashCode(); boolean intersectsRectangle(Rectangle r, boolean bias); double length(); Point pointAlongLineSegment(double distance); LineSegment reverse(); LineSegment subSegment(double offset, double length); @Override String toString(); }
LineSegment { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (!(obj instanceof LineSegment)) { return false; } LineSegment other = (LineSegment) obj; if (other.start.equals(this.start) && other.end.equals(this.end)) { return true; } return false; } LineSegment(Point start, Point end);  LineSegment(Point start, Point direction, double distance); double angleTo(LineSegment other); LineSegment clipToRectangle(Rectangle r); @Override boolean equals(Object obj); @Override int hashCode(); boolean intersectsRectangle(Rectangle r, boolean bias); double length(); Point pointAlongLineSegment(double distance); LineSegment reverse(); LineSegment subSegment(double offset, double length); @Override String toString(); final Point start; final Point end; }