trafficlightu.pas

来自「source for card readers」· PAS 代码 · 共 50 行

PAS
50
字号
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 + =
减小字号Ctrl + -
显示快捷键?