diff --git a/Coding/waitingroom.cpp b/Coding/waitingroom.cpp new file mode 100644 index 0000000..36c8eca --- /dev/null +++ b/Coding/waitingroom.cpp @@ -0,0 +1,135 @@ + +/*This is an implementation of an emergency waiting room in an hospital +where patients are served on first come first serve basis. +Implemented using queues.*/ + + + + + #include + #include + #include + #include + + using namespace std; + + class Patient{ //patient class to store information about patients + + public: + int id; + string name; + }; + + class Waiting_Room{ //wating room class has functions to manage the pateints in the room + + public: + + static queue Patients; + static int id_gen; + + void RegisterPatient(string); + void ServePatient(); + void CancelAll(); + bool CanDoctorGoHome(); + void ShowAllPatient(); + + }; + + int Waiting_Room:: id_gen=1; + queue Waiting_Room::Patients; + + + void Waiting_Room:: RegisterPatient(string _name){ //creatd patient objects and stores them in the patients queue + Patient newPatient; + newPatient.name=_name; + newPatient.id=id_gen++; + Patients.push(newPatient); + cout<<"Patient "< tempRecord; + while(!Patients.empty()){ + tempRecord.push_back(Patients.front()); + Patients.pop(); + } + //sort by alphabetical order + for (int i=0;i