📄 intfunit.pas
字号:
unit IntfUnit;
interface
uses
Classes, SysUtils, Dialogs;
type
IFormattedNumber = interface
['{2DE825C1-EADF-11D2-B39F-0040F67455FE}']
function FormattedString: string;
function GetName: string;
end;
TFormattedInteger = class(TInterfacedObject, IFormattedNumber)
private
FValue: Integer;
public
constructor Create(AValue: Integer);
destructor Destroy; override;
function FormattedString: string;
function GetName: string;
end;
TFormattedHexInteger = class(TFormattedInteger, IFormattedNumber)
public
destructor Destroy; override;
function FormattedString: string;
function GetName: string;
end;
implementation
uses
MainForm;
{ TFormattedInteger }
constructor TFormattedInteger.Create(AValue: Integer);
begin
inherited Create;
FValue := AValue;
end;
destructor TFormattedInteger.Destroy;
begin
Form1.Memo1.Lines.Add('TFormattedInteger.Destroy');
inherited Destroy;
end;
function TFormattedInteger.FormattedString: string;
begin
Result := 'The integer is ' + IntToStr(FValue);
end;
function TFormattedInteger.GetName: string;
begin
Result := 'TFormattedInteger.GetName';
end;
{ TFormattedHexInteger }
destructor TFormattedHexInteger.Destroy;
begin
Form1.Memo1.Lines.Add('TFormattedHexInteger.Destroy');
inherited Destroy;
end;
function TFormattedHexInteger.FormattedString: string;
begin
Result := 'The hex integer is $' + IntToHex(FValue, 4);
end;
function TFormattedHexInteger.GetName: string;
begin
Result := 'TFormattedHexInteger.GetName';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -