program ant;
uses wincrt;
label ok;
label ok2;
const max = 25;
type antrian = record
isi,isi2,isi3,isi4 : array [1..7] of string;
depan , bel : 0..max;
end;
recdata = record
nama,u,jk,k : string;
end;
var a : antrian;
data : array [1..max] of recdata;
i,n : integer;
pil,pil1,pil2,pil3 : char;
pesan : string;
procedure push (var a : antrian ; x : recdata);
begin
if a.bel = max then
writeln ('antrian penuh')
else begin
a.bel := a.bel + 1;
a.isi [a.bel] := x.nama;
a.isi2[a.bel] := x.u;
a.isi3[a.bel] := x.jk;
a.isi4[a.bel] := x.k;
end;
end;
procedure pop (var a : antrian);
begin
for i := 1 to a.bel-1 do
a.isi [i] := a.isi [i+1];
a.isi2[i] := a.isi2[i+1];
a.isi3[i] := a.isi3[i+1];
a.isi4[i] := a.isi4[i+1];
a.bel := a.bel-1;
n := n-1;
end;
procedure lanjut;
begin
writeln ('PRESS ENTER KEY');
readln;
end;
procedure input;
begin
clrscr;
pil := 'y';
while pil ='y' do
begin
clrscr;
n := n+1;
writeln ('antrian ke-' ,n);
writeln ('--------------');
write ('nama : ');readln (data[n].nama);
write ('isi : ');readln (data[n].u);
write ('jumlah : ');readln (data[n].jk);
write ('harga : ');readln (data[n].k);
push (a,data[n]);
writeln;
writeln;
write ('ada pelanggan lagi [y/n]');readln (pil);
writeln;
end;
end;
procedure look2;
begin clrscr;
if a.bel = 0 then
writeln (pesan)
else
begin
for i :=1 to a.bel do
with data [i] do
begin
writeln (' antrian ke-',i);
writeln ('+----------+--------+---------+----------+');
writeln ('| nama | isi | jumlah| harga |');
writeln ('+----------+--------+---------+----------+');
writeln ('|',nama:8, '|' ,u:8, '|',jk:8, '|' ,k:8, '|');
writeln ('+----------+--------+---------+----------+');
writeln; end; end;
lanjut; end;
procedure beres;
begin clrscr;
if a.bel = 0 then
begin
gotoxy (30,15) ; writeln (pesan);
gotoxy (30,26) ;lanjut ;
end else begin
pop (a) ; end;end;
begin pesan := ('tidak ada antrian'); ok: clrscr;
writeln ('+-----------------------------------+');
writeln ('| DAFTAR MENU PILIHAN |');
writeln ('+-----------------------------------+');
writeln ('| 1. Tambah antrian |');
writeln ('| 2. Keluarkan antrian |');
writeln ('| 3. Lihat antrian |');
writeln ('| 4. Exit |');
writeln ('+-----------------------------------+');
writeln;
write ('pilihan [1/2/3/4] : '); readln (pil3);
case pil3 of
'1' : begin
n := 0;
a.depan := 1;
a.bel := 0;
input;
end;
'2' : beres;
'3' : look2;
'4' : halt;
end;
goto ok;
end.
Tidak ada komentar:
Posting Komentar