unit ampel_u;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Shape1: TShape;
Rotlicht: TShape;
Gelblicht: TShape;
Gruenlicht: TShape;
SchalterBtn: TButton;
procedure SchalterBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure schalte(z : byte);
private
{ Private-Deklarationen}
public
{ Public-Deklarationen}
end;
var
Form1: TForm1;
zaehler : byte;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
zaehler := 1;
end;
procedure TForm1.schalte(z:byte);
begin
case z of
1 : begin
Rotlicht.Brush.Color := clRed;
GelbLicht.Brush.Color := clBtnFace;
GruenLicht.Brush.Color := clBtnFace;
end;
2 : begin
Rotlicht.Brush.Color := clRed;
GelbLicht.Brush.Color := clYellow;
GruenLicht.Brush.Color := clBtnFace;
end;
3 : begin
Rotlicht.Brush.Color := clBtnFace;
GelbLicht.Brush.Color := clBtnFace;
GruenLicht.Brush.Color := clGreen;
end;
4 : begin
Rotlicht.Brush.Color := clBtnFace;
GelbLicht.Brush.Color := clYellow;
GruenLicht.Brush.Color := clBtnFace;
end;
end;
end;
procedure TForm1.SchalterBtnClick(Sender: TObject);
begin
inc(zaehler);
if zaehler = 4 then zaehler := 1;
schalte(zaehler);
end;
end.
© Dietrich Praclik