From c849226cff8885a2f147a55e09bbb5dbcfec0804 Mon Sep 17 00:00:00 2001 From: Salman Siddiq Date: Sun, 22 Oct 2023 12:38:52 +0500 Subject: [PATCH] Code for Emergency waiting room in cpp using queue --- Coding/waitingroom.cpp | 135 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 Coding/waitingroom.cpp 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