-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueueTest.cpp
More file actions
45 lines (38 loc) · 1 KB
/
queueTest.cpp
File metadata and controls
45 lines (38 loc) · 1 KB
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
#include <iostream>
#include "myQueue.h"
using namespace std;
int main() {
cout << "Testing the template myQueue, try an integer queue as an example..." << endl;
cout << "Please enter the max size of the int queue: ";
int capacity;
cin >> capacity;
myQueue<int> testIntQ(capacity);
while(1) {
cout << "Please enter 'e' for enqueue, 'd' for dequeue, and 's' for stop." << endl;
char userOption;
cin >> userOption;
if(userOption == 's')
break;
switch(userOption) {
case 'e':
if(!testIntQ.isFull()) {
cout << "Please enter the integer you want to enqueue: ";
int val;
cin >> val;
testIntQ.enqueue(val);
}
else
cout << "Cannot enqueue. The queue is full." << endl;
break;
case 'd':
if(!testIntQ.isEmpty())
cout << testIntQ.dequeue() << " has been popped out." << endl;
else
cout << "Cannot pop. The queue is empty." << endl;
break;
default:
cout << "Illegal input character for options." << endl;
}
}
return 0;
}