public class Line extends Figure implements Drawable{
Point start;
Point end;
//构造方法
Line() {
}
Line(Point start) {
this.start = start;
}
Line(Point start,Point end) {
this.start = start;
this.end = end;
}
//求直线的长度
public double length(Point start,Point end) {
double len = Math.abs(Math.sqrt(Math.pow((start.getX()-end.getX()),2) + Math.pow((start.getY()- end.getY()),2)));
return len;
}
public double length() {
double len = Math.abs(Math.sqrt(Math.pow((start.getX()-end.getX()),2)
- Math.pow((start.getY()- end.getY()),2)));
return len;
}
public void draw() {
System.out.println(“绘制直线”);
}
@Override
public void drow() {
}
}