program Project1;
Uses Classes, SysUtils;
Type
IMyInterface = Interface
Procedure Method1;
Procedure Method2;
Procedure Method3;
end;
{ TSuperClass }
TSuperClass = Class(TInterfacedObject)
Public
Procedure PublicMethod;
end;
TChildClass1 = Class(TSuperClass)
end;
{ TChildClass2 }
TChildClass2 = Class(TSuperClass)
end;
{ TChildClass3 }
TChildClass3 = Class(TSuperClass, IMyInterface)
Public
Procedure Method1;
Procedure Method2;
Procedure Method3;
end;
TChildClass4 = Class(TSuperClass, IMyInterface)
Public
Procedure Method1;
Procedure Method2;
Procedure Method3;
end;
{ TChildClass5 }
TChildClass5 = Class(TSuperClass, IMyInterface)
Public
Procedure Method1;
Procedure Method2;
Procedure Method3;
end;
{ TChildClass5 }
procedure TChildClass5.Method1;
begin
Writeln('Hello From Child5-Method1');
end;
procedure TChildClass5.Method2;
begin
Writeln('Hello From Child5-Method2');
end;
procedure TChildClass5.Method3;
begin
Writeln('Hello From Child5-Method3');
end;
{ TChildClass3 }
procedure TChildClass3.Method1;
begin
Writeln('Hello From Child3-Method1');
end;
procedure TChildClass3.Method2;
begin
Writeln('Hello From Child3-Method2');
end;
procedure TChildClass3.Method3;
begin
Writeln('Hello From Child3-Method3');
end;
procedure TChildClass4.Method1;
Begin
Writeln('Hello From Child4-Method1');
end;
procedure TChildClass4.Method2;
begin
Writeln('Hello From Child4-Method2');
end;
procedure TChildClass4.Method3;
begin
Writeln('Hello From Child4-Method3');
end;
procedure TSuperClass.PublicMethod;
begin
Writeln('Hello from the Superclass');
end;
Procedure CallChildInterface(Const AChild:IMyInterface);
Begin
AChild.Method1;
AChild.Method2;
AChild.Method3;
end;
Var
c1:TChildClass1;
c2:TChildclass2;
c3:TChildClass3;
c4:TChildClass4;
c5:TChildClass5;
begin
c1:=TChildClass1.Create;
c1.PublicMethod;
c1.Free;
c2:=TChildClass2.Create;
c2.PublicMethod;
c2.Free;
c3:=TChildClass3.Create;
c3.PublicMethod;
CallChildInterface(c3);
c3.Free;
c4:=TChildClass4.Create;
c4.PublicMethod;
CallChildInterface(c4);
c4.Free;
c5:=TChildClass5.Create;
c5.PublicMethod;
CallChildInterface(c5);
c5.Free;
ReadLn;
end.