unit Monster2B;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TMonster = class
  private
    Name : String;
    Wesen: String;
  public
    constructor Create (N, W: String);
    procedure Erscheinen;
    class function Typ: String; virtual;
  end;

  TGMonster = class (TMonster)
  public
    class function Typ: String; override;
  end;

  TSMonster = class (TMonster)
  public
    class function Typ: String; override;
  end;

  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Panel1: TPanel;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Frank  : TMonster;
  Albert : TGMonster;
  Sigmund: TSMonster;

implementation

{$R *.DFM}

constructor TMonster.Create (N, W: String);
begin
  Name := N; Wesen := W;
end;

procedure TMonster.Erscheinen;
begin
  Form1.Label1.Caption := 'Name:  ' + Name;
  Form1.Label2.Caption := 'Wesen: ' + Wesen;
  Form1.Label3.Caption := 'Typ:   ' + Typ;
end;

class function TMonster.Typ: String;
begin
  result := 'Monster';
end;

class function TGMonster.Typ: String;
begin
  result := 'GeistesMonster';
end;

class function TSMonster.Typ: String;
begin
  result := 'SeelenMonster';
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Frank   := TMonster.Create  ('Frankie', 'ungewöhnlich');
  Albert  := TGMonster.Create ('Berti', 'nachdenklich');
  Sigmund := TSMonster.Create ('Sigi', 'mitfühlend');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Frank.Erscheinen;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Albert.Erscheinen;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Sigmund.Erscheinen;
end;

end.
