Kemaren waktu di ruang praktikum, sang asdos memberikan tugas untuk
membuat lampu lalulintas menggunakan delphi 7, sebenarnya program ini
sangat sederhana, silahkan saudara - saudara dapat mengembangkannya
sendiri.
\
Berikut source code dari aplikasi diatas :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Shape1: TShape;
Shape2: TShape;
Shape3: TShape;
Label2: TLabel;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
detik:Integer;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
detik:=detik+1;
if ((detik>=0)and (detik<=60)) then
begin
Shape3.Brush.Color:=cllime;
Shape2.Brush.Color:=clwhite;
Shape1.Brush.Color:=clwhite;
Label2.Caption:=IntToStr(detik);
Timer1.Interval:=100;
end
else if ((detik>60)and(detik<=120)) then
begin
Shape2.Brush.Color:=clyellow;
Shape3.Brush.Color:=clwhite;
Shape1.Brush.Color:=clwhite;
Label2.Caption:=IntToStr(detik);
Timer1.Interval:=100;
end
else if ((detik>120)and(detik<180)) then
begin
Shape1.Brush.Color:=clred;
Shape2.Brush.Color:=clwhite;
Shape3.Brush.Color:=clwhite;
Label2.Caption:=IntToStr(detik);
Timer1.Interval:=100;
end
else
begin
detik:=0;
end
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Shape1: TShape;
Shape2: TShape;
Shape3: TShape;
Label2: TLabel;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
detik:Integer;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
detik:=detik+1;
if ((detik>=0)and (detik<=60)) then
begin
Shape3.Brush.Color:=cllime;
Shape2.Brush.Color:=clwhite;
Shape1.Brush.Color:=clwhite;
Label2.Caption:=IntToStr(detik);
Timer1.Interval:=100;
end
else if ((detik>60)and(detik<=120)) then
begin
Shape2.Brush.Color:=clyellow;
Shape3.Brush.Color:=clwhite;
Shape1.Brush.Color:=clwhite;
Label2.Caption:=IntToStr(detik);
Timer1.Interval:=100;
end
else if ((detik>120)and(detik<180)) then
begin
Shape1.Brush.Color:=clred;
Shape2.Brush.Color:=clwhite;
Shape3.Brush.Color:=clwhite;
Label2.Caption:=IntToStr(detik);
Timer1.Interval:=100;
end
else
begin
detik:=0;
end
end;
end.
{ 0 komentar... Views All / Send Comment! }
Post a Comment