procedure TForm1.Timer1Timer(Sender: TObject);
begin
// If the current color is red
if shpRed.Brush.Color = clRed then
begin
// Change the color to green
Timer1.Interval := 3500;
shpRed.Brush.Color := clSilver;
shpYellow.Brush.Color := clSilver;
shpGreen.Brush.Color := clGreen;
end
// But if the color is green
else if shpGreen.Brush.Color = clGreen then
begin
// Change the color to yellow
Timer1.Interval := 2000;
shpRed.Brush.Color := clSilver;
shpYellow.Brush.Color := clYellow;
shpGreen.Brush.Color := clSilver;
end
// Otherwise, if the color is yellow
else // if(shpYellow->Brush->Color == clYellow
begin
// Change the color to red
Timer1.Interval := 5000;
shpRed.Brush.Color := clRed;
shpYellow.Brush.Color := clSilver;
shpGreen.Brush.Color := clSilver;
end;
end;
end.
|