Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment you will implement a small hospital appointment system, where patients can book appointments. The program should be able to take a patients

  • In this assignment you will implement a small hospital appointment system, where patients can book appointments. The program should be able to take a patient’s information and the appointment that they’d like to book and assigns them to a doctor according to their availability. It should also be able to display the patients’ names in order of their appointments (ascendingly). Classes inheritance and overloading First, Implement the following classes as explained below. 1. Class Person : An abstract parent class that has the following: Member variables: Name ID Age. Methods(member functions): A default constructor setters getters printInfo: a print function that prints the person’s information. 2. Struct Appointment: struct that has the following member variables: hours mins. Note: You can assume we’re using the 24 hours system) 3. Class Patient : child class inherits from class Person with the following: Private variables: doctorID: to indicate the ID of the doctor assigned to their case. (can be any number) appointment: struct of the type defined in the previous step to indicate the patients appiontment with the dr. Member functions: setters getters Overload the ,== operators for class Person compare between patients’ appointments. Example: two patients are equal if their appointments have the same values for hours and minutes. 4. Class Doctor: inherits from Person with the following: Private variables : counter : number of appointments the Dr has for the day Array of struct (appointment): that indicates the times the Dr is booked. Methods: isAvailable: A function that returns true if the Dr is available at a certain time, false if not. setters getters Template Class Queue Second, implement a generic queue class to work with any data type. The class should at least support the following functions: Push Pop Hospital Appointment program Finally, combine the three classes(Person, Patient, Doctor) and Queue class to simulate a hospital appointment system. The hospital system works as follows: 1. The hospital has a number of doctors available. 2. The patients come and choose an appointment time. 3. The system chooses the first doctor avialable in the appointment time chosen by the user and assigns this doctor to the user. 4. We assume that a doctor is available 24 hours each day until a patient reserves one time slot. i.e. A doctor is not available at a certain time only if a patient already reserved this time, otherwise assume the doctor is available. 5. If there are no avaialable doctors in the time chosen by the patient, then the patient will appointment will be cancelled. i.e. when printing the patients, print a message indicating that no doctors were found for this patient. Program Workflow : 1. You could read multiple Doctor’s data from the user or initialize them within the main function. 2. Read multiple patients’ data from from the user. Insert patients with their appointment into an array of patients. 3. The program should assign each patient to the doctors in the order the doctors are stored so the first patient would go to the first doctor, and the second patient to the second doctor and so on till you go back to the first doctor. 4. If a doctor is not available in the appointment the patient chose, then the next doctor should be considered and so on. Tip: Use the doctor class functions to check the doctor’s availability. 5. The patients should be inserted into a queue in order of their appointments. For example, the patient with earlier appointment is stored at the beginning of the queue and the patient with the latest appoint is stored at the end. Tip: use the overloaded operators for the Patient class to compare between them. 6. Print the information of the patients in order, along with the info of their assigned doctor. Test Case: Input: Patients: Ahmed at 1:00, Sara at 4:00, and Kareem at 3:00, Mohammed 1:00 Doctors : Ayman, Khaled, Mai Output: Ahmed should be assigned to Dr Ayman 1:00 Sara should be assigned to Dr Khaled at 4:00 Kareem should be assigned to Dr Mai at 3:00 Mohammed should be assigned to Dr Khaled at 1:00 (since Dr Ayman is unavailable at 1:00 and Dr Khaled is next in the array) After inserting the patients to the queue, they should be in the following order: Ahmed has an appointment at: 1:00. with Dr Ayman Mohammed has an appointment at 1:00 with Dr Khaled Kareem has an appointment at 3:00 with Dr Mai Sara has an appointment at: 4 : 0. with Dr Khaled Bonus: Use files for the input. Store the input for the patients/doctors in a file and allow your program to read the input from the file directly. We read the file line by line and save the data in the corresponding variables in the program. So each time we run the program the array of patients/doctors can be already filled with data ( In which case we don’t take them from the user) Example for the doctors.txt: Mai // Dr name 40 // Dr age 1 // Dr ID 3 // number of appointments, should be followed by number of appointments*2 lines that indicate the hour & mins of each appointment. 1 // appointment 1 at 1:00 0 5 // appointment 1 at 5:30 30 3 // appointment 3 at 3:15 15 Then we read for each doctor in the array of doctors : doctor x; x.name= ((The first line which is Dr name)) x.age= ((The second line which is Dr age)) x.ID= ((The third line which is doctor ID )) Then loop according to the number of appointments(given in line 4) to read the time of each appointment line by line into the x.appointments array. So the hours for appointment 1, for example, would be stored in x.appointments[0].hours, and the minutes for appointment 1 would be stored in x.appointments[0].mins. Tips: to read patients/doctors from a file easily, make sure to use the same format for each Dr/Patient in the text file. Guidelines & Resources 1. Optionally, divide your classes in separate files, each class should have a header file and a .cpp file to keep your code more organised and readable. 2. Please make sure to document your code by adding comments that explain your logic and the functions you’re creating whenever possible. Preferrably the comments for classes would be in the header file(if exists). 3. For each class: it is important implement setters/getters for the private member variables. Don't make a member variable public unless necessary. 4. Some resources that might help you:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Elementary Principles of Chemical Processes

Authors: Richard M. Felder, Ronald W. Rousseau

3rd Edition

978-0471687573, 9788126515820, 978-0-471-4152, 0471720631, 047168757X, 8126515821, 978-0471720638

More Books

Students also viewed these Chemical Engineering questions

Question

7. One or other combination of 16.

Answered: 1 week ago

Question

5. It is the needs of the individual that are important.

Answered: 1 week ago