/* "has-a relationship" --> composition */
/* a line segment "has" two points
 * or is "composed of" two points */
public class LineSegment {
  Point p1;
  Point p2;

  public LineSegment(int x1, int y1, int x2, int y2) {
    p1 = new Point(x1, y1);
    p2 = new Point(x2, y2);
  }

  /* overloaded the constructor */
  public LineSegment(Point a, Point b) {
    p1 = a;
    p2 = b;
  }

  public boolean equals(LineSegment o) {
    return p1.equals(o.p1) &&
        p2.equals(o.p2);
  }

  public LineSegment brokenClone() {
    return new LineSegment(p1, p2);
  }
  
  public LineSegment clone() {
    return new LineSegment(p1.clone(), p2.clone());
  }

  public String toString() {
    return "[" + p1 + " " + p2 + "]";
  }
}

