CAN YOU HELP ME TO SOLVE THIS Assignment....
PLEASE....
THIS IS THE QUESTION :
Implement the linkedPriorityQueue class as defined below. Note the following:
Each node in linkedPriorityQueue represents a customer. A customer can be regular or
with a high priority. High-priority customers have their high_priority variable set to true
while regular customers have their high_priority variable set to false.
To implement the idea of a priority queue, class linkedPriorityQueue maintains two
queues: one for high-priority customers (implemented using the high_priority_front
and high_priority_rear pointers) and one for regular customers (implemented using the
queue_front and queue_rear pointers).
When adding a new customer, both the customer’s number and his/her priority level is
provided. The customer should be added to the appropriate queue based on his/her priority.
When serving (deleting) a customer, high-priority customers are considered first (i.e., a regular
customer cannot be served while a high-priority customer is waiting).
The front function returns the number of the high-priority customer who has been waiting the
most, while the back function returns the number of the regular customer who has been
waiting the least.
The print function prints the contents of the queue starting with high-priority customers (see
the example below).
The size function takes a boolean argument, high_priority, and returns the number of
high-priority customers in the queue if high_priority is true and the number of regular
customers otherwise.
Do not forget to include proper documentation for your code. 10% of your grade depends on
the documentation. Each function and each variable must be accompanied with a comment
describing its functionality. Do not forget to include your name, ID and section in each file you
submit.
The provided main function is for testing/grading purposes. The only modification allowed on
this function is to comment/uncomment parts of it for debugging purposes.
Your program should compile correctly. Submissions with compilation errors will not be
accepted.
Included below is the expected output of the main function.
Good Luck!
THIS IS MAIN FOR HELP TO FIND THE SOLUTION
#include <iostream>
#include <cassert>
using namespace std;
struct node {
int number;
bool high_priority;
node *link;
;{
class linkedPriorityQueue {
private:
node *high_priority_front,
*high_priority_rear,
*queue_front,
*queue_rear;
public:
linkedPriorityQueue();
void addQueue( int number, bool high_priority );
void deleteQueue();
int front();
int back();
bool empty();
bool full();
void print();
int size( bool high_priority);
~linkedPriorityQueue();
;{
int main() {
bool t;
int i, j;
linkedPriorityQueue q1;
for( i = 0; i < 9; i++ ) {
t = bool( rand() % 2 );
q1.addQueue( i, t );
cout<<"Customer "<<i<<( t ? " with high-priority " : " " )<<"aded to the queue."<<endl;
{
q1.addQueue( i, true );
cout<<"Customer "<<i<<" with high-priority aded to the queue."<<endl;
cout<<"\nThe number of high-priority customers is "<<q1.size( true )
<<",\nwhile the number of remaining customers is "<<q1.size( false )<<"."<<endl;
cout<<"\nCustomer number "<<q1.front()<<" is at the front of the queue,"
<<"\nwhile customer number "<<q1.back()<<" is at the end of the queue."<<endl;
cout<<endl;
q1.print();
j = q1.size( true ) + q1.size( false ) / 2;
for( i = 0; i < j; i++ )
q1.deleteQueue();
cout<<"\nAfter a few removals, the number of high-priority customers is "<<q1.size( true )
<<",\nwhile the number of remaining customers is "<<q1.size( false )<<"."<<endl;
cout<<"\nCustomer number "<<q1.front()<<" is at the front of the queue,"
<<"\nwhile customer number "<<q1.back()<<" is at the end of the queue."<<endl;
cout<<endl;
q1.print();
return 0;
{