unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Memo1: TMemo; Button2: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ProcedClose(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} //--------- Definice typu ------------------------------- type TZvire = class Druh : String; constructor Inicializuj; function Zvuky: String; virtual; procedure Tisk; end; TPes = class(TZvire) constructor Inicializuj; function Zvuky: String; override; end; TKocka = class(TZvire) constructor Inicializuj; function Zvuky: String; override; end; //--------- Implementace metod -------------------------- constructor TZvire.Inicializuj; begin Druh := 'Zvire ' end; function TZvire.Zvuky: String; begin Zvuky := 'nezname' end; procedure TZvire.Tisk; begin Form1.Memo1.Text:=Form1.Memo1.Text+Druh+Zvuky+chr(13)+chr(10); end; //-------------------------------- constructor TPes.Inicializuj; begin Druh := 'Pes ' end; function TPes.Zvuky: String; begin Zvuky := 'steka' end; //-------------------------------- constructor TKocka.Inicializuj; begin Druh := 'Kocka ' end; function TKocka.Zvuky: String; begin Zvuky := 'mnouka' end; //------------------------------------------------------- //--------- Deklarace objektu --------------------------- var U1,U2,U3 : TZvire; Micka : TKocka; Filipes : TPes; //------------------------------------------------------- //--------- Hlavni program ------------------------------ procedure TForm1.Button1Click(Sender: TObject); begin Memo1.Text:=''; //-------------------------------- Filipes := TPes.Inicializuj; Filipes.Tisk; U1 := TZvire.Inicializuj; U1.Tisk; Micka := TKocka.Inicializuj; Form1.Memo1.Text:=Form1.Memo1.Text+Micka.Druh+Micka.Zvuky+chr(13)+chr(10); U2 := TKocka.Inicializuj; U2.Tisk; //-------------------------------- Micka.Free; Filipes.Free; U1.Free; U2.Free; U3.Free; end; //------------------------------------------------------- procedure TForm1.FormCreate(Sender: TObject); begin Form1.Memo1.Text:=' Uloha: c.1 .................'; end; procedure TForm1.ProcedClose(Sender: TObject); begin close; end; end.