20-CS-122-001 Computer Science II Spring 2012
Doctors' Office Simulation

Virtual functions, classes, inheritance, lists, queues, stacks, applications

We model the flow of patients through a doctors' office. Assume there are some number of doctors associated with a given doctors' office. Also, there is a receptionist. Suppose further that there are some number of patients that are serviced by the doctors' office.

All well patients become sick eventually. When that happens, they pay a visit to the doctors' office. The doctors' office consists of a waiting room full of sick patients and a pool of doctors to serve them. The waiting room and the doctor pool are both managed by a receptionist. Patients in the waiting room are waiting to be served by doctors and doctors in the doctor pool are "available" to serve patients. The office system functions as follows:

  1. When a patient arrives at the doctors' office, he or she immediately enters the waiting room.
  2. At any moment, as long as there are doctors in the doctor pool and patients in the waiting room, and as long as new arrivals are no longer being processed, patients in the waiting room are paired with doctors in the doctor pool in first-come-first-serve order.
  3. When a patient is paired with a doctor, they remain paired for some random period of time. After that period elapses, the doctor is returned to the doctor pool and the patient is sent home.
  4. The patient remains at home for some random period of time. After that period elapses the patient returns to the doctors' office for treatment.

Source Code:
    plist.h     Include file for the PList class (priority and normal queue)
    plist.cc     Source for the PList class
    doctor.h     Include file for the Doctor class
    doctor.cc     Source for the Doctor class
    patient.h     Include file for the Patient class
    patient.cc     Source for the Patient class
    event.h     Include file for the Event class
    event.cc     Source for the Event class
    eventmanager.h     Include file for the EventManager class
    eventmanager.cc     Source for the EventManager class
    receptionist.h     Include file for the Receptionist class
    receptionist.cc     Source for the Receptionist class
    docs.cc     Contains the main procedure for running the simulation
    Makefile     The Makefile

    docpat.pdf     Sample simulation