Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description In the assignment, you will implement a Patient Priority Queue Type class that manages a waiting line of patients to be processed at a

image text in transcribedimage text in transcribedimage text in transcribed

Description In the assignment, you will implement a Patient Priority Queue Type class that manages a waiting line of patients to be processed at a hospital. Because queues that process elements in a first-in, first-out (FIFO) order does not give a priority to the patient with urgent case, FIFO queue is not the best order to assist patients in a hospital, so you need to implemented as priority queue instead of ordinary queue. When new patient checks in at the hospital, a nurse assesses their injuries and gives that patient an integer priority value. The smaller integers represent a greater urgency. For example, a patient of priority 1 has more urgent situation than a patient of priority 2 and should receive a faster medical care. When a doctor is ready to see a patient, the patient with the highest priority (smallest priority integre) is served first. That is, regardless of the order in which you addQueue the patient nodes, the patient with the smallest priority integer is dequeued first (deleted), then the patient with second-smallest priority integer and so on, with the largest priority item coming out last. When two patients have the same priority values, FIFO principle is applied. In other words, the one that came first is seen by the doctor first. You need to implement a linked based version of the patient priority queue. Specifically, you need to implement the classes: PatientType, PatientNode, and Patient Priority Queue Type. The class specifications are presented in the UMLs diagrams shown in Figures 1, 2, and 3. The PatientPriority Queue does not need to store its nodes in sorted order; all needed is that when the elements are dequeued(deleted), they come out in sorted order by priority, and when several patients have the same priority, the one that comes first should be served first. The following are description of the classes you need to implement: PatientType is the class that define the attributes of a patient including the patient First Name, the last name, age, and priority value. It is very important to implement a default constructor beside the parametrized constructor, otherwise you will get a syntax error. PatientNode is the class that defines the node to be added to the Patient Priority Queue. Each node of the type PatientNode has the object of the type PatientType to store that patient information and the patient priority, and a link (pointer) called next that points to the next node in the queue. Patient Priority Queue Type is used to maintain and manipulate information of the patients. An object of the type Patient Priority Queue Type is a list of nodes of type PatientNode. The node are not need to store its nodes in sorted order; all needed is that when the elements are dequeued(deleted), they come out in sorted order by priority, and when several patients have the same priority, the one that comes first should be served first. Duplicated names and priorities are allowed. class PatientType ( 8 pts) + Firts Name: string // the first name of the patient + LastName: string // The last name of the patient + age: int // The patient's age + Priority_value: int // priority rate of patient case, it should be 1 or greater + PatientType (string, string, int, int=1) // 3 pts) Parameterized constructor. If the user tries to assign a priority value less than one, your code should turn it to 1. + PatientType() //( 2 pts) default constructor that set the FirtsName and the LastName of the patient to empty strings, age to 40 and priority to 1. + printPatientinfo()://( 3 pts) print the patient info as in the example: [Ahmad Ali, 28 years, priority =2] Figure 1: UML of the class PatientType class PatientNode ( 2 pts) + patient: PatientType // the info of the patient + next: PatientNode Figure 2: UML of the class PatientNode class PatientPriorityQueue Type ( 30 pts) queueFront: PatientNode* queueRear: PatientNode* + Patient PriorityQueue Type() //( 1 pts) default constructor + - PatientPriorityQueueType() // (1 pts) destructor + isEmpty(): bool //( 1 pts) Function to determine whether the queue is empty. Returns true if the queue is empty, otherwise returns false. + isFull(): bool;// ( 1 pts) Function to determine whether the queue is full. Returns true if the queue is full, otherwise returns false. However, it is implemented using linked list so never gets full + initializePriorQueue():void //( 3 pts) Function to initialize the queue to an empty state. + printPriorityQueue():void //( 3 pts) Function print the contents of the priority queue , each patient's info in a separated line enQueue and deQueue Functions addPatient (Patient Type newPatient): void //( 5 pts) add a patient to the queue, the nodes are needed to be sorted by priority, duplicated names and priority are allowed. + deletePatient():void//(10) function you should remove the patient with the most urgent priority from your queue. + frontPatient():void; //(5) In this function you should print the name , the age and the priority value of the most urgent patient (the patient with the lowest priority value), without removing it from the queue. Figure 3: UML of the class Patient PriorityQueue Type Important notes: 1. The implementation of PatientType and PatientNode and PatientPriorityQueue Type should be placed in a file called Patient Priority Queue.h. Please Implement the function outside the class. Please add the time complexity of each function as a comment before the function header. Your test code should be placed in the main() function in a file called main.cpp 2. implement the classes and their function as specified in the UML (by the comment). 3. You must write a code to test the functions you implemented. You are responsible for designing test code the helps us to see if your functions are implemented properly. In the test code, you define an object of the class PatientPriorityQueue and call the functions. You need to place your test code inside a file called main.cpp. During grading, we are also going to use our one test code to check if your code is written properly or not. 4. Give the function deletePatient extra importance in the testing, the function should work properly in the following cases: the queue is empty, the queue has one element there is more than one patient with the same priority value, for those you need to apply FIFO principle the node to be deleted is the last in the queue other cases if any. Obj of class Patient Type Obj of class PatientNode Ruba Khalid 30 Ahmad Ali 45 3 Faisal Saeed 51 1 queue Front queue Rear

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions