unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 =
class(TForm)
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private-Deklarationen}
public
{ Public-Deklarationen}
end;
var
Form1: TForm1;
implementation
const
maxplatz = 20;
type
Menge =
set of 1..maxplatz;
var
freiplatz,besetzt : Menge;
a,b : integer;
{$R *.DFM}
procedure TForm1.Button2Click(Sender: TObject);
Begin
close;
End;
procedure TForm1.FormActivate(Sender: TObject);
Begin
Edit1.text:='
';
freiplatz:=[1..maxplatz];
For a:=0
to maxplatz
do
if a
in freiplatz
then
Begin
Label1.Caption:=Label1.Caption+inttostr(a)+'
';
End;
End;
procedure TForm1.Button1Click(Sender: TObject);
Begin
b:=strtoint(Edit1.text);
if b
in freiplatz
then
Begin
freiplatz:=freiplatz-[b];
Label1.Caption:='
';
Edit1.text:='
';
For a:=0
to maxplatz
do
if a
in freiplatz
then
Begin
Label1.Caption:=Label1.Caption+inttostr(a)+'
';
End;
End
else
Begin
if (b>maxplatz)
or (b=0)
or (b<0)
then
Begin
showmessage('
Der Bus hat nicht genug Plätze!');
Edit1.text:='
';
End
else
showmessage('
Bitte buchen Sie einen anderen Platz, welcher noch nicht belegt ist!');
Edit1.text:='
';
End;
End;
End.