Question: 5 parts: main.cpp/ heap.h/Hea.cpp/ Printjob.h/ Printjob.cpp Implement a max-heap to manage print jobs. You are given the PrintJob class Class PrintJob PrintJob.h #ifndef #de fine
5 parts: main.cpp/ heap.h/Hea.cpp/ Printjob.h/ Printjob.cpp
Implement a max-heap to manage print jobs. You are given the PrintJob class Class PrintJob PrintJob.h #ifndef #de fine PRINT-JOB H PRINTJOBH using namespace std; class PrintJob private: int priority; int jobNumber; int numPages public: PrintJob int, int, int) int getPriority int getJobNumber int getPages //You can add additional functions here #endif PrintJob.cpp #include "PrintJob "h" PrintJob::PrintJob ( nt setP, int setJ, int numP ) :priority (setP), jobNumber(setJ), numPages (numP) int PrintJob::getPriority return priority; int PrintJob::getJobNumber return jobNumber; int PrintJob: : getPages return numPages; class Heap #ifndef HEAPH #de fine HEAPH #include "PrintJob . h" const int MAXHEAPSIZE = 10; - - class Heap f private: PrintJob* arr [MAX HEAP SIZE) int numItems //current number of items in heap // Notice this is an array of PrintJob pointers public: Initializes an empty heap. Heap) /Inserts a PrintJob to the heap without violating max-heap properties.* void enqueue PrintJob*) *Removes the node with highest priority from the heap. Follow the algorithm on priority-queue slides. void dequeue *Returns the node with highest priority*/ PrintJob highest *Prints the PrintJob with highest priority in the following format: Priority: priority, Job Number jobNum, Number of Pages: numPages (Add a new line at the end.)*/ void print ) private: /This function is called by dequeue function to move the new root down the heap to the appropriare location.*/ void trickleDown (int); //You can include additional private helper functions here #endif main.cpp Use the following main function to test your program: #include #include "Heap . h" using namespace std; int menu) ( int choice = 0; cout > choice; // fix buffer just in case non-numeric choice entered // also gets rid of newline character cin.clear ); cin.ignore (256, 'n) return choice; int main) Heap max_heap; int choice = menu(); while (choice != 4) { if (choice1) int priority, obNumber, numPages; cout priority>>jobNumber>>numPages; max_heap.enqueue (new PrintJob (priority, jobNumber, numPages)); else if (choice =-2) max_heap.print O else if (choice3) ( max_heap.dequeue)i //fix buffer just in case non-numeric choice entered choicemenu) return 0; Implement a max-heap to manage print jobs. You are given the PrintJob class Class PrintJob PrintJob.h #ifndef #de fine PRINT-JOB H PRINTJOBH using namespace std; class PrintJob private: int priority; int jobNumber; int numPages public: PrintJob int, int, int) int getPriority int getJobNumber int getPages //You can add additional functions here #endif PrintJob.cpp #include "PrintJob "h" PrintJob::PrintJob ( nt setP, int setJ, int numP ) :priority (setP), jobNumber(setJ), numPages (numP) int PrintJob::getPriority return priority; int PrintJob::getJobNumber return jobNumber; int PrintJob: : getPages return numPages; class Heap #ifndef HEAPH #de fine HEAPH #include "PrintJob . h" const int MAXHEAPSIZE = 10; - - class Heap f private: PrintJob* arr [MAX HEAP SIZE) int numItems //current number of items in heap // Notice this is an array of PrintJob pointers public: Initializes an empty heap. Heap) /Inserts a PrintJob to the heap without violating max-heap properties.* void enqueue PrintJob*) *Removes the node with highest priority from the heap. Follow the algorithm on priority-queue slides. void dequeue *Returns the node with highest priority*/ PrintJob highest *Prints the PrintJob with highest priority in the following format: Priority: priority, Job Number jobNum, Number of Pages: numPages (Add a new line at the end.)*/ void print ) private: /This function is called by dequeue function to move the new root down the heap to the appropriare location.*/ void trickleDown (int); //You can include additional private helper functions here #endif main.cpp Use the following main function to test your program: #include #include "Heap . h" using namespace std; int menu) ( int choice = 0; cout > choice; // fix buffer just in case non-numeric choice entered // also gets rid of newline character cin.clear ); cin.ignore (256, 'n) return choice; int main) Heap max_heap; int choice = menu(); while (choice != 4) { if (choice1) int priority, obNumber, numPages; cout priority>>jobNumber>>numPages; max_heap.enqueue (new PrintJob (priority, jobNumber, numPages)); else if (choice =-2) max_heap.print O else if (choice3) ( max_heap.dequeue)i //fix buffer just in case non-numeric choice entered choicemenu) return 0