Social Icons

Pages

Featured Posts

Simulasi Sistem Antrian Loket

Simulai Antrian adalah sistem antrian dengan pengambilan nomer antrian untuk menunggu panggilan dengan beberapa loket panggilan. Berikut ini adalah cara membuat program sistem antrian dengan pengmabilan nomer antrian dan 3 loket :





procedure TForm1.Timer1Timer(Sender: TObject); // MENJALANKAN PROSES ANTRIAN
var int1,int2,int3,i : integer;
begin
if Edit1.Text = '0' then else
   Edit1.Text :=  IntToStr(StrToInt(Edit1.Text)-1);
if Edit2.Text = '0' then else
   Edit2.Text :=  IntToStr(StrToInt(Edit2.Text)-1);
if Edit3.Text = '0' then else
   Edit3.Text :=  IntToStr(StrToInt(Edit3.Text)-1);
end;

procedure TForm1.Button1Click(Sender: TObject); // MENJALANKAN PROSES ANTRIAN
var
  int1,int2,int3,i   : Integer;
begin
  ListBox1.ItemIndex := 0;

if ( ListBox1.ItemIndex = -1 ) then
begin
   if MessageDlg('TUNGGU ANTRIAN !'+#13+
                 'Ambil nomor antrian', mtWarning,
   [mbOK], 0) = mrOK  then
end else
begin
  int1 := 15 + Random(5);
  int2 := 14 + Random(6);
  int3 := 15 + Random(5);

  Edit1.Text := IntToStr(int1);
  Edit2.Text := IntToStr(int2);
  Edit3.Text := IntToStr(int3);

  ListBox1.ItemIndex := 0;
  i:=ListBox1.ItemIndex;
  proses1.Color := clWhite;
  proses1.Caption := ListBox1.Items.Strings[i];
  Listbox1.Items.Delete(i);

  proses2.Color := clWhite;
  proses2.Caption := ListBox1.Items.Strings[i];
  Listbox1.Items.Delete(i);

  proses3.Color := clWhite;
  proses3.Caption := ListBox1.Items.Strings[i];
  Listbox1.Items.Delete(i);
end;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject); // MENGAMBIL NOMER ANTRIAN
begin
ambil.Text := IntToStr(StrToInt(ambil.Text)+1);
ListBox1.Items.Add(ambil.Text);
end;

procedure TForm1.waktuprosesExecute(Sender: TObject);
var i : integer;
begin
  ListBox1.ItemIndex := 0;
  if ( ListBox1.ItemIndex = -1 ) then exit;
  i:=ListBox1.ItemIndex;
  Panel5.Caption := ListBox1.Items.Strings[i];
  Listbox1.Items.Delete(i);
end;

procedure TForm1.waktu1Click(Sender: TObject);
begin
if waktu1.Caption = '2' then
   waktu1.Color := clRed;
end;

procedure TForm1.Edit1Change(Sender: TObject);
var i,int : integer;
begin
if Edit1.Text = '4' then
   begin
   proses1.Caption := 'selesai';
   end;
if Edit1.Text = '2' then
   begin
   proses1.Color := clRed;
   proses1.Caption := 'panggil';
   end;
if Edit1.Text = '0' then
   begin
     ListBox1.ItemIndex := 0;
     if ( ListBox1.ItemIndex = -1 ) then exit;
     i:=ListBox1.ItemIndex;
     proses1.Caption := ListBox1.Items.Strings[i];
     Listbox1.Items.Delete(i);
     int := 15 + Random(5);
     proses1.Color := clWhite;
     Edit1.Text := IntToStr(int);
   end;

end;

procedure TForm1.Edit2Change(Sender: TObject);
var i,int : integer;
begin
if Edit2.Text = '4' then
   begin
   proses2.Caption := 'selesai';
   end;
if Edit2.Text = '2' then
   begin
   proses2.Color := clRed;
   proses2.Caption := 'panggil';
   end;
if Edit2.Text = '0' then
   begin
     ListBox1.ItemIndex := 0;
     if ( ListBox1.ItemIndex = -1 ) then exit;
     i:=ListBox1.ItemIndex;
     proses2.Caption := ListBox1.Items.Strings[i];
     Listbox1.Items.Delete(i);
     int := 15 + Random(5);
     proses2.Color := clWhite;
     Edit2.Text := IntToStr(int);
   end;

end;

procedure TForm1.Edit3Change(Sender: TObject);
var i,int : integer;
begin
if Edit3.Text = '4' then
   begin
   proses3.Caption := 'selesai';
   end;
if Edit3.Text = '2' then
   begin
   proses3.Color := clRed;
   proses3.Caption := 'panggil';
   end;
if Edit3.Text = '0' then
   begin
     ListBox1.ItemIndex := 0;
     if ( ListBox1.ItemIndex = -1 ) then exit;
     i:=ListBox1.ItemIndex;
     proses3.Caption := ListBox1.Items.Strings[i];
     Listbox1.Items.Delete(i);
     int := 15 + Random(5);
     proses3.Color := clWhite;
     Edit3.Text := IntToStr(int);
   end;
end;

DOWNLOAD SOURCE #1

DOWNLOAD SOURCE #2



Belajar Pemprograman Delphi

Ternyata belajar pemprograman Delphi sangat gampang ya.. ^__^

begin
  if pintar = rajin_belajar then
    berhasil else
    gagal;
end;
 
Blogger Templates