unit Monster7A;

interface

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

type
  TMonster = class
  public
    procedure Erscheinen (BildName: String);
  end;

  TForm1 = class(TForm)
    Button1: TButton;
    Image1: TImage;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

const Pfad = '.\bilder\';   // 'c:\delphi\buch\bilder\';
var
  Form1: TForm1;
  WerWohl: TMonster;
  Zufall : Integer;

implementation

{$R *.DFM}

procedure TMonster.Erscheinen (BildName: String);
begin
  Form1.Image1.Picture.LoadFromFile (Pfad+BildName);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  randomize;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Button1.Caption := 'Weiter';
  try
    try
      WerWohl := TMonster.Create;
      Zufall := random(6);
      case Zufall of
        0: WerWohl.Erscheinen ('Frank.bmp');
        1: WerWohl.Erscheinen ('Albert.bmp');
        2: WerWohl.Erscheinen ('Sigmund.bmp');
        3: WerWohl.Erscheinen ('Jekyll.bmp');
        4: WerWohl.Erscheinen ('Hyde.bmp');
        5: WerWohl.Erscheinen ('Test.xxx');
      end;
    except
      Button1.Caption := 'Kein Bild';
    end;
  finally
    Werwohl.Free;
  end;
end;

end.
