Extensions

uses System.Math;

type
  TPoint = class
  public
    X, Y: Double;
    constructor Create(AXAYDouble);
  end;

  TPointHelper = class helper for TPoint
    //type method added by the helper
    class function GetDistance(
      P1P2TPoint): Doublestatic;
  end;

constructor TPoint.Create(AXAYDouble);
begin
  X := AX;
  Y := AY;
end;

class function TPointHelper.GetDistance(
  P1P2TPoint): Double;
begin
  Result := Sqrt(Power(P1.X - P2.X2) +
    Power(P1.Y - P2.Y2));
end;

var
  P1P2TPoint;
begin
  P1 := TPoint.Create(12);
  P2 := TPoint.Create(23);

  WriteLn('distance is ',
    TPoint.GetDistance(P1P2):0:4);
  //distance is 1.4142
end.