program antrian tiket

Rabu, 16 Februari 2011 Uses wincrt;
Const Loket = 55;
Kanan = 75;
UpBound = 11;
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] := (' -( )- ');
Badan[3] := ('__/^\__');
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);
If X = 75 Then
Begin
GotoXY(X,Y); Clreol;
GotoXY(X,Y+1); Clreol;
GotoXY(X,Y+2); Write('______');

End;
Until X = Mentok;
End;

Procedure Antrian.input;
Var Pil : char;
Begin
GotoXY(1,2); Write('1. Bikin Antrian');
GotoXY(1,3); Write('2. Antrian Masuk');
GotoXY(1,4); Write('3. Antrian Keluar');
GotoXY(1,5); Write('4. Bye..Bye..');
GotoXY(1,6); Write(' PILIHAN [1..4] ? ');
Pil := Readkey; Write(Pil); Out := Pil;
End;

Procedure Antrian.create;
Var I : integer;
Begin
For I := 18 To 22 Do
Begin
GotoXY(1,I); Clreol;
end;
For I := 1 To 80 Do Write('_');
GotoXY(58,17); Write(' ANTRIAN KARCIS');
GotoXY(60,18); Write(' _______');
GotoXY(60,19); Write(' /_______\');
GotoXY(60,20); Write(' /-| | | | |-\');
GotoXY(60,21); Write(' | | | | | ');
GotoXY(60,22); Write(' __| LOKET |__');
GotoXY(60,23); Noel := 0;
End;

Procedure Antrian.Insertion;
Begin
If Noel >= upbound Then
Begin
GotoXY(3,23);
Write('Antrian Penuh');
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,23);
Write(' Antrian kosong'); Noel := 0;
End
Else
Begin
Dec(Noel);
GotoXY(55,20); Write(' ');
GotoXY(55,21); Write(' ');
GotoXY(55,22); Write('_______');
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
Noel := 0;
Repeat
Input(Menu);
GotoXY(1,23); Clreol;
Case Menu Of
'1' : Create;
'2' : Insertion;
'3' : Deletion;
End;
until Menu = '4';
End;

{* PROGRAM UTAMA *}

Var Queue : Antrian;
Begin
Clrscr;

writeln ( ' program antrian tiket ' );
queue.doproses;
End.

0 komentar:

Posting Komentar

 
 
 
 
Copyright © Oes blog