📄 trafficlightu.pas
字号:
unit TrafficLightU;
interface
uses Forms;
type
TTrafficLight = class (TObject)
public
procedure NextState (AClient: TForm);
end;
implementation
uses LightControlU, // to access the properties
Graphics; // for TColor
{ TTrafficLight }
procedure TTrafficLight.NextState (AClient: TForm);
begin
if (AClient is TfrmTrafficLight) then
with TfrmTrafficLight(AClient)do
begin
if State = 'Stop' then
begin
Period := 3000;
State := 'Go';
StopLight := clBlack;
GoLight := clGreen;
end
else if State = 'Go' then
begin
Period := 1000;
State := 'Caution';
GoLight := clBlack;
CautionLight := clYellow;
end
else
begin
Period := 4000;
State := 'Stop';
CautionLight := clBlack;
StopLight := clRed;
end;
end;
end; // end procedure TTrafficLight.NextState
end. // end unit TrafficLightU
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -