unit Unit2;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,System.Generics.Collections,System.UITypes;
type
TForm2 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure WMSysCommand(
var Message: TMessage);
message WM_SYSCOMMAND;
public
{ Public-Deklarationen }
end;
IDrafi =
Interface ['
{876A9480-49D2-4735-A95F-AF21015CF372}']
function Kracks:integer;
end;
TMarmor =
class(TInterfacedObject,IDrafi)
function Kracks:integer;
end;
TStein =
class(TInterfacedObject,IDrafi)
function Kracks:integer;
end;
TUnd =
class(TInterfacedObject,IDrafi)
function Kracks:integer;
end;
TEisen =
class(TInterfacedObject,IDrafi)
function Kracks:integer;
end;
TBricht =
class(TInterfacedObject,IDrafi)
function Kracks:integer;
end;
procedure UnsereLiebe(LstDrafi:TList<IDrafi>);
var
Form2: TForm2;
LstDrafi:TList<IDrafi>;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var i,n:integer;
Drafi:IDrafi;
begin
If Assigned(LstDrafi)
then FreeAndNil(LstDrafi);
LstDrafi := TList<IDrafi>.Create;
LstDrafi.Capacity := 100;
For i := 1
to 20
do begin
For n := 1
to 5
do begin
Case n
of
1: Drafi := TMarmor.Create;
2: Drafi := TStein.Create;
3: Drafi := TUnd.Create;
4: Drafi := TEisen.Create;
5: Drafi := TBricht.Create;
End;
LstDrafi.Add(Drafi);
end;
end;
UnsereLiebe(LstDrafi);
end;
procedure UnsereLiebe(LstDrafi:TList<IDrafi>);
var i:integer;
begin
For i := 0
to LstDrafi.Count - 1
do
If LstDrafi[i].Kracks = mrCancel
then break;
end;
function TMarmor.Kracks:integer;
begin
Result := mrOK;
Showmessage('
Marmor...');
end;
function TStein.Kracks:integer;
begin
Result := mrOK;
Showmessage('
...Stein...');
end;
function TUnd.Kracks:integer;
begin
Result := mrOK;
Showmessage('
...und...');
end;
function TEisen.Kracks:integer;
begin
Result := mrOK;
Showmessage('
...Eisen bricht.');
end;
function TBricht.Kracks:integer;
begin
Result := MessageDlg('
Abää unsärä Liihiebe nischt!',mtInformation,[mbOk,mbCancel], 0, mbOk);
end;
procedure TForm2.WMSysCommand(
var Message: TMessage);
begin
If Message.WParam = SC_CLOSE
then LstDrafi.Free;
inherited;
end;
end.