📄 usayhello.pas
字号:
unit uSayHello;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs;
type
ISpeakLanguage = interface (IInterface)
function SayHello: string;
end;
ISpeakChinese = interface (ISpeakLanguage)
//function SayHello: string;
end;
ISpeakEnglish = interface (ISpeakLanguage)
//function SayHello: string;
end;
TMan = class (TInterfacedObject)
private
FName: string;
public
property Name: string read FName write FName;
end;
TChinese = class (TMan, ISpeakChinese)
private
function SayHello: string;
end;
TAmerican = class (TMan, ISpeakEnglish)
private
function SayHello: string;
end;
TAmericanChinese = class (TMan, ISpeakChinese, ISpeakEnglish)
public
constructor create;
function SayHello: string;
end;
implementation
{
********************************** TAmerican ***********************************
}
function TAmerican.SayHello: string;
begin
result:='Hello!';
end;
{
*********************************** TChinese ***********************************
}
function TChinese.SayHello: string;
begin
result:='你好!';
end;
{
******************************* TAmericanChinese *******************************
}
constructor TAmericanChinese.create;
begin
name:='Tom Wang';
end;
function TAmericanChinese.SayHello: string;
var
Dad: ISpeakChinese;
Mum: ISpeakEnglish;
begin
Dad:=TChinese.Create;
Mum:=TAmerican.Create;
result:=Dad.SayHello+Mum.SayHello;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -