Monday, July 11, 2011

Line

package com.evs.objava33.class6;

public class Line {

// double x1, y1, x2, y2;
Point start, end;

public Line(double x1, double y1, double x2, double y2) {
start = new Point(x1, y1);
end = new Point(x2, y2);
}

public Line(final Point start, final Point end) {
this.start = start;
this.end = end;
}

public Line(final Line line) {
this.start = line.start;
// this.start = new Point(line.start.getX(), line.start.getY());
this.end = line.end;
}

public double length() {
return start.distance(end);
}

public String toString() {
return "Line [start=" + start + ", end=" + end + "]";
}

}

No comments:

Post a Comment