You are on page 1of 4

Program NonCircular_Single_linked_List_LIFO_OR_FIFO;

UsesCrt;
Const
A='Action'; {konstanta}
D='Drama';
K='Komedi';
Type
Str5 = String[5];
PointVCD= ^RecVCD;
RecVCD = Record
KdVCD :Str5;
Jns :String[10];
JdlVCD :String[20];
Jml :Byte;
Next :PointVCD; {pointer}
End;
Var
Head, Tail, Now : PointVCD;
Procedure Judul1; {Tampilan Judul Aplikasi}
Begin
ClrScr;
WriteLn('Blue Sky VCD Rental House');
WriteLn('Jl. Kemanggisan Tengah');
WriteLn('Jakarta Tenggara');
GotoXY(26,5);WriteLn('Pendataan VCD');
GotoXY(26,6);WriteLn('=============');
End;
Procedure Judul2; {Tampilan Judul untuk input}
Begin
GotoXY(21,8);WriteLn('Kode VCD [A/D/K] : xxxxx');
GotoXY(21,8);WriteLn('Jenis VCD : x-xxxxx');
GotoXY(21,8);WriteLn('Judul VCD : xxxxxxxxxxx');
GotoXY(21,8);WriteLn('Jumlah VCD : 9');
End;
Procedure Buat_Simpul_FIFO; {Simpul untuk FIFO}
Begin
New(Now); {Membuat Simpul Baru}
if head=nil then {Mendeteksi ada/tidak simpul}
begin
Now^.next:=nil;
Head:=Now;
Tail:=Now;
end else
begin
Tail^.next:=Now;
Tail:=Now;
Tail^.next:=nil;
end;
end;
End;
Procedure Buat_Simpul_LIFO; {Simpul untuk FIFO}
Begin
new(Now);
if head=nil then
begin
now^.next:=nil; {Belum ada simpul}
else
now^.next:=head; {Sudah ada simpul}
head:=now;
end;
end;
Procedure Besar (var Kode:Str5; {Mengubah huruf kecil ke Besar}
Var i:byte;
Begin
for i:=1 to lenght (Kode) do
Kode [i]:= Upcase (Kode[i]);
end;
Procedure Input;
Var
n :byte;
pil :char;
temp :Str5;
begin
n:=0;
Head:=ni; Tail:=nil; {simpul awal dan akhir dikosongkan}
ClrScr;
Judul1;
GotoXY(21,7); Write('LIFO or FIFO [L/F] : ');
Repeat
GotoXY(42,7); ClrEol; Pil:=Upcase (readkey);
Until Pil in ['L','F'];
Repeat
ClrScr;
Judul1;
Judul2;
Repeat
GotoXY(41,8); readln(temp); Besar(temp);ClrEol;
GotoXY(21,9); Write('Jenis VCD :x-xxxxx');
Until((temp[1] in ['A','D','K']) Or (temp=''));
if temp<>'' then
begin
inc(n);
if Pil='L' then
Buat_Simpul_LIFO {menjalankan LIFO}
else
Buat_Simpul_FIFO;{Menjalankan FIFO}
if temp[1] ='A' then
begin
now^.jns:=A;
GotoXY(41,9); write('A-',A);
end else
if temp[1] ='D' then
begin
now^.jns:=D;
GotoXY(41,9); write('D-',D);
end else
if temp[1] ='K' then
begin
now^.jns:=K;
GotoXY(41,9); write('K-',K);
end;
now^.KdVcd:=temp;
GotoXY(41,10); readln(now^.JdlVCD);{Membaca Input}
GotoXY(41,11); readln(now^.Jml);
end;
Until (temp='') or (n=10);
end;
Procedure Output; {Prosedur Membuat Laporan}
Var y : byte;
begin
ClrScr;
Judul1;
GotoXY(26,5);WriteLn('D A F T A R V C D');
GotoXY(26,6);WriteLn('==================');
GotoXY(17,8);WriteLn('KdVCD Jenis Film Judul Video CD Jumlah');
GotoXY(17,9);WriteLn ('=============================================');
(*****************************************)
(* Menampilkan Data2 yg ada *)
(*****************************************)
Now:=Head; y:=9;
while (now<>nil) do
begin
inc (y);
GotoXY(17,Y); WRITE (now^.KdVCD);
GotoXY(28,Y); WRITE (now^.jns);
GotoXY(45,Y); WRITE (now^.JdlVCD);
GotoXY(65,Y); WRITE (now^.Jml);
now:=now^.next;
end;
Readkey;
(*****************************************)
(* Hapus simpul2 yang telah dibuat *)
(*****************************************)
Now:=Head;
while (Now<>nil) do
begin
Head:=Now^.next;
dispose(now);
Now:=Head;
end;
Begin {Main Program}
Input;
Output;
End;

You might also like