|
| 1 | +#include <iostream> |
| 2 | +#include "Queue.cpp" |
| 3 | +using namespace std; |
| 4 | + |
| 5 | +int main() |
| 6 | +{ |
| 7 | + cQue queue; |
| 8 | + /* |
| 9 | + This is a check to see if the Queue is empty by using isEmpty function |
| 10 | + */ |
| 11 | + cout << "This is a check to see if the Queue is empty by using isEmpty function. " << endl; |
| 12 | + if (queue.isEmpty()) |
| 13 | + { |
| 14 | + cout << "Queue is empty." << endl |
| 15 | + << endl; |
| 16 | + } |
| 17 | + else |
| 18 | + { |
| 19 | + cout << "Queue is not Empty." << endl |
| 20 | + << endl; |
| 21 | + } |
| 22 | + |
| 23 | + /* |
| 24 | + This is a check to see if the Queue is empty by using isEmpty function. |
| 25 | + */ |
| 26 | + cout << "This is a check to see if the Queue is empty by using isEmpty function." << endl; |
| 27 | + if (queue.isNotEmpty()) |
| 28 | + { |
| 29 | + cout << "Queue is not empty." << endl |
| 30 | + << endl; |
| 31 | + } |
| 32 | + else |
| 33 | + { |
| 34 | + cout << "Queue is Empty." << endl |
| 35 | + << endl; |
| 36 | + } |
| 37 | + |
| 38 | + /* |
| 39 | + This is a check to see all the elements present in the queue by printing them. |
| 40 | + */ |
| 41 | + cout << "This is a check to see all the elements present in the queue by printing them." << endl; |
| 42 | + queue.print(); |
| 43 | + cout << endl; |
| 44 | + |
| 45 | + /* |
| 46 | + Declaring a node and setting the data |
| 47 | + */ |
| 48 | + cNode *ptr = new cNode(102); |
| 49 | + /* |
| 50 | + Pushing the new node into the Queue whose address is stored in ptr into the Queue |
| 51 | + */ |
| 52 | + queue.add(ptr); |
| 53 | + |
| 54 | + /* |
| 55 | + This is a check to see if the Queue is empty or not using empty function. |
| 56 | + */ |
| 57 | + cout << "This is a check to see if the Queue is empty or not using empty function." << endl; |
| 58 | + if (queue.isEmpty()) |
| 59 | + { |
| 60 | + cout << "Queue is empty." << endl; |
| 61 | + } |
| 62 | + else |
| 63 | + { |
| 64 | + cout << "Queue is not Empty." << endl |
| 65 | + << endl; |
| 66 | + } |
| 67 | + |
| 68 | + /* |
| 69 | + Now printing the data present in the Queue |
| 70 | + */ |
| 71 | + cout << "Printing the data present in the Queue using print function." << endl; |
| 72 | + queue.print(); |
| 73 | + |
| 74 | + /* |
| 75 | + Deleting the latest node from the Queue using remove function when only one node is present in the Queue |
| 76 | + */ |
| 77 | + queue.remove(); |
| 78 | + /* |
| 79 | + After Deleting first latest node from Queue, printing the Queue |
| 80 | + */ |
| 81 | + cout << "After Deleting latest node from Queue, printing all the data in the Queue." << endl; |
| 82 | + queue.print(); |
| 83 | + |
| 84 | + /* |
| 85 | + Now iniializing a node and setting data using setData fuction. |
| 86 | + */ |
| 87 | + cNode *newNode = new cNode(); |
| 88 | + newNode->setData(431); |
| 89 | + queue.add(newNode); |
| 90 | + cout << "\nNow iniializing a node and setting data using setData function. " << endl; |
| 91 | + queue.print(); |
| 92 | + /* |
| 93 | + Now declaring few more nodes and setting data using set Data function and pushing them to queue |
| 94 | + */ |
| 95 | + |
| 96 | + cNode *node2 = new cNode(); |
| 97 | + node2->setData(324); |
| 98 | + queue.add(node2); |
| 99 | + |
| 100 | + cNode *node3 = new cNode(); |
| 101 | + node3->setData(235); |
| 102 | + queue.add(node3); |
| 103 | + |
| 104 | + cNode *node4 = new cNode(); |
| 105 | + node4->setData(833); |
| 106 | + queue.add(node4); |
| 107 | + |
| 108 | + cNode *node5 = new cNode(); |
| 109 | + node5->setData(424); |
| 110 | + queue.add(node5); |
| 111 | + |
| 112 | + cNode *node6 = new cNode(); |
| 113 | + node6->setData(145); |
| 114 | + queue.add(node6); |
| 115 | + |
| 116 | + cNode *node7 = new cNode(); |
| 117 | + node7->setData(524); |
| 118 | + queue.add(node7); |
| 119 | + |
| 120 | + /* |
| 121 | + Now Queue will be returned if isNotEmpty function returns true. |
| 122 | + */ |
| 123 | + cout << "\n\nNow Queue will be printed if isNotEmpty function returns true." << endl; |
| 124 | + if (queue.isNotEmpty()) |
| 125 | + queue.print(); |
| 126 | +} |
0 commit comments