-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_queue.cpp
74 lines (72 loc) · 1.95 KB
/
test_queue.cpp
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
#include <iostream>
#include <string>
#include "Queue.hpp"
int main()
{
using std::cout;
using std::endl;
using std::cin;
short option;
std::string word;
Queue<std::string> queue;
cout << "Program testujący kolejkę.\n";
do
{
cout << "1 - wyczyść kolejkę\n";
cout << "2 - sprawdź czy kolejka jest pusta\n";
cout << "3 - sprawdź ilość elementów\n";
cout << "4 - dodaj element\n";
cout << "5 - zwróć element z początku\n";
cout << "6 - usuń element\n";
cout << "7 - wydrukuj kolejkę\n";
cout << "8 - zakończ\n";
cin >> option;
switch (option)
{
case 1:
queue.clear();
break;
case 2:
cout << (queue.is_empty() ? "Jest pusta." : "Nie jest pusta.") << endl;
break;
case 3:
cout << queue.size() << " elementów.\n";
break;
case 4:
cout << "Słowo: ";
cin >> word;
queue.enqueue(word);
break;
case 5:
try
{
word = queue.front();
}
catch (Queue<std::string>::NoElement)
{
cout << "Kolejka jest pusta.\n";
break;
}
cout << word << endl;
break;
case 6:
try
{
queue.dequeue();
}
catch (Queue<std::string>::NoElement)
{
cout << "Kolejka jest pusta.\n";
}
break;
case 7:
queue.print();
break;
case 8:
return 0;
default:
cout << "Niewłaściwa opcja.\n";
}
}
while (true);
}