public class LineSegment {
  private int x1, y1, x2, y2;

  public LineSegment() {
    x1 = 0;
    y1 = 0;
    x2 = 0;
    y2 = 0;
  }

  public LineSegment(int startX, int startY, int endX, int endY) {
    x1 = startX;
    y1 = startY;
    x2 = endX;
    y2 = endY;
  }

  public LineSegment(LineSegment other) {
    x1 = other.x1;
    y1 = other.y1;
    x2 = other.x2;
    y2 = other.y2;
  }

  public int getX1() { return x1; }
  public int getY1() { return y1; }
  public int getX2() { return x2; }
  public int getY2() { return y2; }

  public void setX1(int newX1) { x1 = newX1; }
  public void setY1(int newY1) { y1 = newY1; }
  public void setX2(int newX2) { x2 = newX2; }
  public void setY2(int newY2) { y2 = newY2; }

  public void move(int dx, int dy) {
    x1 += dx;
    y1 += dy;
    x2 += dx;
    y2 += dy;
  }

  public double length() {
    int dx = x2 - x1;
    int dy = y2 - y1;
    return Math.sqrt(dx * dx + dy * dy);
  }

  public boolean equals(LineSegment other) {
    return (x1 == other.x1 && y1 == other.y1 && x2 == other.x2 && y2 == other.y2) ||
        (x1 == other.x2 && y1 == other.y2 && x2 == other.x1 && y2 == other.y1);
  }

  public String toString() {
    return "(" + x1 + "," + y1 + ") -> (" + x2 + "," + y2 + ")";
  }
}
