-
Notifications
You must be signed in to change notification settings - Fork 0
/
queue.h
80 lines (72 loc) · 1.76 KB
/
queue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef queue_h
#define queue_h
#include <iostream>
using namespace std;
struct mobil {
string A[5];
int BATAS, data=-1;
};
class car {
public:
mobil y;
bool isEmpty(){
if(y.data == -1){
return true;
}
return false;
}
void batas(int n){
y.A[n];
y.BATAS = n-1;
}
bool isFull(){
if(y.data ==y.BATAS ){
return true;
}
else{
return false;
}
}
void enqueue(string x){
if(isFull()){
cout<<"========================="<<endl;
cout<<"\n==ANTRIAN SUDAH PENUH=="<<endl;
cout<<"========================="<<endl;
}
else{
y.data++;
y.A[y.data] = x;
cout<<"\n====================================="<<endl;
cout<<"== Antrian mobil berhasil masuknih =="<<endl;
cout<<"=====================================\n"<<endl;
}
}
void dequeue(){
if(isEmpty()){
cout<<"\n=================================="<<endl;
cout<<"== tidak ada mobil yang ngantri =="<<endl;
cout<<"=================================="<<endl;
}
else{
cout<<"\n\n=================================="<<endl;
cout<<"Mobil "<<y.A[y.data-1]<<" udah keluar niihh"<<endl;
cout<<"=================================="<<endl;
for(int i=0;i<y.data;i++){
y.A[i] = y.A[i+1];
}
y.data--;
}
}
void tampil(){
if(isEmpty()){
cout<<"\n\no> Antrian kosong "<<endl;
}
else{
for(int i=0;i<=y.data;i++){
cout<<endl<<y.A[i]<<" ";
}
cout<<"\n\no> Total Mobil yang di Antrian = "<<y.data+1<<endl;
}
}
};
#endif