1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| class Point2Ds
{
public int X;
public int Y;
public Point2Ds(int x, int y)
{
this.X = x;
this.Y = y;
}
public int Distance(Point2Ds point)
{
double temp = Math.Sqrt(((this.X - point.X) * (this.X - point.X) + (this.Y - point.Y) * (this.Y - point.Y)));
return (int)(temp);
}
}
class Segment2Ds /* extend */ : Point2Ds
{
public int X2;
public int Y2;
public Segment2Ds(int x1, int y1, int x2, int y2)
{
super(x1, y1);
this.X2 = x2;
this.Y2 = y2;
}
public int Longueur()
{
return this.Distance(new Point2Ds(X2, Y2));
}
} |