CS301 Data Structures Assignment No. 2 Solution and Discussion Fall 2014 Due Date: Dec 08, 2014


Uploading instructions

For clarity and simplicity, you are required to Upload/Submit only .cpp file.
Objective

Sponsored Links

The objective of this assignment is:

To make you understand the practical implementation of queue data structure.
Problem Statement:

Suppose in a Hospital, there are two physicians to deal with patients. Patients of all ages come for their check up. Physician ‘A’ is designated as physician of old patients while physician ‘B’ has to check other patients. Many patients come to the hospital at the same time. There are two queues of patients against each physician. If patient is an old man, he will stand in second queue; otherwise he will stand in first queue. Both doctors check their patients one by one on first come first served basis. Due to timing restriction of the hospital, each doctor can check a maximum of 20 patients per day.

You are required to write a program in C++ to implement the above scenario. It should be clear that patients will be added on back/rear side of the queue and will be served from front of the queue. Further, your program should use array to implement above scenario.

Model of one of the patients’ queues (array part) is given below.

cs301.jpg


Solution Guidelines:

You are required to implement queue as an array.
Your solution should contain two classes Patient class and PatientQueue class.
Patient class should be able to set patients’ information given in above model.
Further, your program should implement the following operations for PatientQueue class / data structure.
In main() function, you have to create two patient queues; one to store records of old patients, and one to store record of other patients.
Each queue should be populated based on age factor; for example if age is less than 50, patient should be added in first queue otherwise in second queue.
Add_Patient() : add new patient in the queue
Display_Patient_Phy1() : Show all Patients information treated by Physician A.
Display_Patient_Phy2() : Show all Patients information treated by Physician B.
Total_Patients() : Show the total number of patients served on a particular day.
Hint: Array index should hold Patient type object. In case of integer type array, you store an integer type data on array index. Here, as you have to store patient type data in array (queue), so patient object will be added on array index.



Sample Output:

For sample output, see the attached .GIF file.
CS301_Assignment_02_SampleOuuput.jpg