public class LineSegment implements Shape, Cloneable, java.io.Serializable {
  // Constructors
  public LineSegment() {
    beginx=0;
    beginy=0;
    endx=0;
    endy=0;
  }

  public LineSegment(float x1, float y1, float x2, float y2){
    beginx = x1;
    beginy = y1;
    endx = x2;
    endy = y2;
  }

  // Accessors
  public float getBeginx() {
    return beginx;
  }

  public float getBeginy() {
    return beginy;
  }

  public float getEndx() {
    return endx;
  }

  public float getEndy() {
    return endy;
  }

  // Canonical form methods
  public boolean equals(Object other) {
    if (this==other) {
      return true;
    }

    if (other instanceof LineSegment) {
      LineSegment otherObj=(LineSegment) other;

      if (beginx!=otherObj.beginx) {
        return false;
      }

      if (beginy!=otherObj.beginy) {
        return false;
      }

      if (endx!=otherObj.endx) {
        return false;
      }

      if (endy!=otherObj.endy) {
        return false;
      }

      return true;
    }

    return false;
  }

  public int hashCode() {
    int hash=0;

    hash=hash*37+(int) startx;
    hash=hash*37+(int) starty;
    hash=hash*37+(int) endx;
    hash=hash*37+(int) endy;

    return hash;
  }

  public Object clone() throws CloneNotSupportedException {
    LineSegment result=(LineSegment) super.clone();

    return result;
  }

  public String toString(){
    String returnString;
    returnString = "LineSegment from: (" + beginx + "," + beginy + ") to (" + endx + "," + endy + ")";
    return returnString;
  }

  // Mutators
  public void setBeginx(float f) {
    beginx=f;
  }

  public void setBeginy(float f) {
    beginy=f;
  }

  public void setEndx(float f) {
    endx=f;
  }

  public void setEndy(float f) {
    endy=f;
  }

  // Fields
  protected float beginx, beginy, endx, endy;
}