Program Parkiran;
Uses Crt;
Const Loket = 55;
Kanan = 75;
UpBound = 5;
LowBound = 1;
Type Orang = Object
Badan : Array[1..3] Of String[6];
X,Y,Mentok : Byte;
Procedure init;
Procedure gerak;
End;
Antrian = object
Queue : Array[LowBound..UpBound] Of Orang;
Noel : integer;
Procedure Input(Var Out : Char);
Procedure Create;
Procedure insertion;
Procedure deletion;
Procedure doproses;
End;
Procedure Orang.Init;
Begin
X := 1; Y := 20; Mentok := Loket;
Badan[1] := (' ');
Badan[2] := (' <[MB] ');
End;
Procedure Orang.Gerak;
Begin
repeat
GotoXY(X,Y); Write(Badan[1]);
GotoXY(X,Y+1); Write(Badan[2]);
GotoXY(X,Y+2); Write(Badan[3]);
Inc(X); GotoXY(16,6); Delay(20);
If X = 75 Then
Begin
GotoXY(X,Y); Clreol;
GotoXY(X,Y+1); Clreol;
Delay(20);
End;
Until X = Mentok;
End;
Procedure Antrian.input;
Var Pil : char;
Begin
GotoXY(1,2); Write('1. Enqueue');
GotoXY(1,3); Write('2. Dequeue');
GotoXY(1,4); Write('3. Quit');
GotoXY(1,5); Write('PILIHAN [1..3] ? ');
Pil := Readkey; Write(Pil); Out := Pil;
End;
Procedure Antrian.create;begin
GotoXY(1,19); Write('________________________________________________________________________________ ');
GotoXY(1,18); Write('<-------------------------Jalur Masuk (Jalur A)<-------------------------------- ');
GotoXY(1,22); Write('________________________________________________________________________________ ');
GotoXY(1,26); Write('------------------------>Jalur Keluar (Jalur B)--------------------------------> ');
GotoXY(1,27); Write('________________________________________________________________________________ ');
GotoXY(1,30); Write('________________________________________________________________________________ ');
End;
Procedure Antrian.Insertion;
Begin
If Noel >= upbound Then
Begin
GotoXY(3,21);
Write('Parkiran Sudah Penuh'); readln;
gotoxy(3,21);
write(' ');
Noel := UpBound;
End
Else
Begin
Inc(Noel); Queue[Noel].Init;
Queue[Noel].Mentok := (Loket - Noel * 5) + 5;
Queue[Noel].Gerak;
End;
End;
Procedure Antrian.Deletion;
Var I : integer;
Front : Orang;
Begin
If Noel < lowbound Then
Begin
GotoXY(59,21);
Write('Mobil Sudah Tidak ada');
End
Else
Begin
Dec(Noel);
GotoXY(55,21); Write(' ');
GotoXY(35,29); Write(' [MB]> ');
readln;
GotoXY(35,29); clreol;
Front := Queue[1];
Front.Mentok := 75;
Front.X := 72;
Front.Gerak;
For I := 1 To Noel Do Queue[I].X := Queue[I+1].X;
For I := 1 To Noel Do Queue[I].Gerak;
End;
End;
Procedure Antrian.DoProses;
Var Menu : char;
Begin
create;
Noel := 0;
Repeat
Textcolor(15); Input(Menu);
GotoXY(1,23); Clreol;
Case Menu Of
'1' : Insertion;
'2' : Deletion;
End;
until Menu = '3';
End;
{* PROGRAM UTAMA *}
Var Queue : Antrian;
Begin
Clrscr;
queue.doproses;
End.
Tidak ada komentar:
Posting Komentar