урок на делфи 21 - светофор


задание на delphi. сфетофор в ручном и автоматическом режиме


unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
Shape1: TShape;
Shape2: TShape;
Shape3: TShape;
RadioGroup1: TRadioGroup;
Timer1: TTimer;
CheckBox1: TCheckBox;
procedure RadioGroup1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked=true then
Timer1.Enabled:=true
else
Timer1.Enabled:=false;
end;
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
case RadioGroup1.ItemIndex of
0: begin Shape1.Brush.Color:=clRed; Shape2.Brush.Color:=clWhite; Shape3.Brush.Color:=clWhite end;
1: begin Shape2.Brush.Color:=clYellow; Shape1.Brush.Color:=clWhite; Shape3.Brush.Color:=clWhite end;
2: begin Shape3.Brush.Color:= clGreen; Shape1.Brush.Color:=clWhite; Shape2.Brush.Color:=clWhite end;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Tag:=Timer1.Tag+1;
RadioGroup1.ItemIndex:=Timer1.Tag;
if Timer1.Tag=3 then
Timer1.Tag:=-1;
end;
end.



Скачать