unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls;
type
TForm1 =
class(TForm)
Label1: TLabel;
wuerfeln: TButton;
beenden: TBitBtn;
summeED: TEdit;
anzahlED: TEdit;
procedure beendenClick(Sender: TObject);
procedure wuerfelnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.beendenClick(Sender: TObject);
begin
close;
end;
procedure TForm1.wuerfelnClick(Sender: TObject);
var summe,anzahl,i:integer;
begin
i:=1;
summe:=0;
anzahl:=0;
anzahl:=strtoint(anzahlED.text);
while (i<=anzahl)
do
begin
summe:=summe+random(6)+1;
i:=i+1;
end;
summeED.Text:=inttostr(summe);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
randomize;
end;
end.