Case Study (Quarantine Center Management System) in oop in c++

 Quarantine Center Management System

As you know now a days the world is going through the COVID-19 pandemic. People are getting themselves tested to see if they have corona virus or not. If they have positive result they are being isolated in Quarantine Centers for 14 days and if recovered, they are sent to their homes with safety precautions (same for negative results they are sent to their homes).
In view of this scenario you have to use object oriented programming concepts to manage the patients in quarantine center.
Now let’s see the management in center:
There is a Quarantine Center in which Patients are admitted in case they are declared positive with Corona Virus after having a test. To do so, there is a class named Quarantine_Center having data member(s) center_id, location, quantity_of_beds (should be defined by default i.e. 20), no_of_patients and contact number. Person contains person_id (unique), first_name, last_name, gender, age and blood_group. A Patient is inherited from Person class and have its own data member(s) i.e.  bed_no (auto assigned should not exceed more then 20, an exception of “Center is Full” should be thrown) and test_result. Test result is generated through Corona_Test class with data members result, date, time and count (total results). Corona_Test is part of Patient class and it will help in generating the result (whether positive or negative). The result is generated randomly using random function. Patients have no particular number defined as many patient wants to come can come, the number of patients will be counted on runtime and that will be the value of no_of_patients in Quarantine_Center class. If the patient have negative result he/she should not be counted in Quarantine_Center class. Patient(s) in center are treated by a Doctor (having name, age, and specialty). The health status of a patient in center is also maintained whether recovering or not. If patient is dead/recovered its count is decremented and the bed gets empty.


       
#include<iostream>

#include<string>

using namespace std;

class Quarentine_Center{

protected:

          int center_id, quantity_of_bed;int no_of_patients;

          string location, contact_no;

public:

          Quarentine_Center(int a,int b,int e,string c,string d)

          {

                   center_id = a;

                   if (b <= 20)

                   { quantity_of_bed = b; }

                   else

                             cout << "Beds are not enough" << endl;

                   if (e <= 20)

                             no_of_patients = e;

                   else

                             cout << "Beds are not enough" << endl;

                   location = c; contact_no = d;

          }

          void centerdetail()

          {

                   cout << "Quantity of beds are:" << quantity_of_bed << endl;

                   cout << "Number of patients are:" << no_of_patients << endl;

                   cout << "Location is:" << location << endl;

                   cout << "Contact number is:" <<contact_no << endl;

          }

 

};

class Person{

protected:

          int person_id[20], age[20];

          string first_name[20], last_name[20], gender[20], blood_group[20];

public:

          int size; int get;

          void entry()

          {

                   cout << "Enter the number of patients:";

                   if (size <= 20)

                   {

                             cin >> size;

                   }

 

                   else

                   {

                             cout << "20 beds available only" << endl;

                             entry();

                   }

                   for (int i = 0; i < size; i++)

                   {

                             cout << endl << endl;

                             cout << "Enter the person id:";

                             cin >> person_id[i];

                             for (int j = 0; j < size; j++)

                             {

                                      if (person_id[0] == person_id[j+1])

                                      {

                                                cout << "Id is same for both" << endl;

                                                cout << "Therefore this id is set to 0" << endl;

                                                person_id[i] = 0;

                                      }

                             }

                             cout << "Enter the age:";

                             cin >> age[i];

                             cout << "Enter the first name:";

                             cin.ignore();

                             getline(cin, first_name[i]);

                             cout << "Enter the last name:";

                             getline(cin, last_name[i]);

                             cout << "Enter the gender:";

                             getline(cin, gender[i]);

                             cout << "Enter the blood group:";

                             getline(cin, blood_group[i]);

                   }

          }

          void show(int a)

          {

                   for (int i = 0; i < size; i++)

                   {

                             if (person_id[i] == a)

                             {

                                      cout << "Your Name is:" << first_name[i] << " " << last_name[i] << endl;

                                      cout << "Your age is:" << age[i] << endl;

                                      cout << "Your blood group is:" << blood_group[i] << endl;

                                      cout << "Your gender is:" << gender[i] << endl;

                             }

                             else

                                      cout << "This id is not found" << endl;

                   }

          }

          int getid(int i)

          {

                   return person_id[i];

          }

 

};

class Patient:public Person{

protected:

          int bed_no[20]; bool test_result[20];

public:

          int temp;

          Patient(){};

          void enterpat()

          {

                   int aa;

                   system("cls");

                   cout << "How much patint do you want to enter to assign beds:";

                   cin >> aa;

                   for (int i = 0; i<aa; i++)

                   {

                             cout << "Enter the bed numbers for this id patient " << person_id[i] << " :";

 

                             cin >> bed_no[i];

                             for (int j = 0; j < aa; j++)

                             {

                                      if (bed_no[0] == bed_no[j + 1])

                                      {

                                                cout << "Two beds are same" << endl;

                                                cout << "Therefor bed is set to 0" << endl;

                                                bed_no[i] = 0;

                                      }

                             }

                   }

                   pro();

          }

          void pro()

          {

                   int a;

                   cout << "Enter the id to enter the result:";

                   cin >> a;

                   for (int i = 0; i < size; i++)

                   {

                             if (person_id[i] == a)

                             {

                                      int b;

                                      cout << "Your patient name is:" << first_name[i] << " " << last_name[i] << endl;

                                      cout << endl << endl;

                                      cout << "Press 1 to confirm that this is your patient(if not than press other number):";

                                      cin >> b;

                                      try{

                                                if (b == 1)

                                                {

                                                          cout << "Enter the result of this patient(press 1 for positive and 0 for negative):";

                                                          cin >> test_result[i];

                                                }

                                                else

                                                {

                                                          throw test_result[i];

                                                }

                                      }

                                      catch (...)

                                      {

                                                cout << "Ok!!    This is not your patient" << endl;

                                      }

                                      int cc;

                                      cout << "If you want to enter result again than put 1:";

                                      cin >> cc;

                                      if (cc == 1)

                                      {

                                                pro();

                                      }

                                      else

                                      {

                                                cout << "ok!!!" << endl;

                                      }

                             }

                   }

          }

          void showresult(int a)

          {

                   for (int i = 0; i < size; i++)

                   {

                             if (a == person_id[i])

                             {

                                      cout << "Your result is:" << test_result[i] << endl;

                             }

                   }

          }

          int getbed(int i)

          {

                   return bed_no[i];

          }

          bool getresult(int i)

          {

                   return test_result[i];

          }

};

class Corona_Test{

protected:

          bool result[20];

          string date[20], time[20];

public:

          static int count;

          void enterdata(Patient &p1)

          {

                   for (int i = 0; i < p1.size; i++)

                   {

                             cout << endl << endl;

                             cout << "Enter the date and time for this id " << p1.getid(i) <<":"<< endl;

                             cout << "Enter the date:";

                             cin.ignore();

                             getline(cin, date[i]);

                             cout << "Enter the time:";

                             getline(cin, time[i]);

                             result[i] = p1.getresult(i);

                   }

          }

          void show_patiant(Patient &p1)

          {

                   for (int i = 0; i < p1.size; i++)

                   {

                             cout << "Id is:" << p1.getid(i) << endl;

                             cout << "Result is:" << result[i] << endl;

                             cout << "Date and time of all tests are:" << endl;

                             cout << "Date is:" << date[i] << endl;

                             cout << "Time is:" << time[i] << endl;

                             cout << endl << endl << endl;

                   }

          }

          void counterwork(Patient &p1)

          {

                   for (int i = 0; i < p1.size; i++)

                   {

                             if (p1.getresult(i) == 1)

                             {

                                      count++;

                             }

                   }

          }

          void check_health_status(Patient &a)

          {

                   int c;

                   cout << "Enter the id number to check the heath status:";

                   cin >> c;

                   a.show(c);

                   a.showresult(c);

          }

          void showcount()

          {

                   cout << "Total Patients are:" << count << endl;

                   cin.get();

                   getchar();

          }

          void death()

          {

                   cout << "Patient is dead" << endl;

                   count--;

          }

};

class Doctor{

protected:

          string name[20], spaciality[20]; int age[20];

public:

          Doctor(Patient &p1)

          {

                   for (int i = 0; i < p1.size; i++)

                   {

                             system("cls");

                             cout << "Enter the detail of doctor for patient:" << p1.getid(i) << endl;

                             cout << "Enter the age of this doctor:";

                             cin >> age[i];

                             cout << "Enter the name of doctor:";

                             cin.ignore();

                             getline(cin, name[i]);

                             cout << "Enter the spaciality of this doctor:";

                             getline(cin, spaciality[i]);

                   }

          }

          void doctor_detail(Patient &p1)

          {

                   int a;

                   cout << "Enter the id of patient to check the doctor:";

                   cin >> a;

                   for (int i = 0; i < p1.size; i++)

                   {

                             if (a == p1.getid(i))

                             {

                                      cout << "Doctor for patient:" << p1.getid(i) << " is:" << name[i] << endl;

                                      cout << "Spaciality of this doctor is:" << spaciality[i] << endl;

                                      cout << "Age of this doctor is:" << age[i] << endl;

                             }

                   }

          }

 

};

int Corona_Test::count;

int main()

{

          Quarentine_Center q1(20, 18, 17, "Gulberge Lahore", "987654321");

          Person p1; Patient pp; Corona_Test c1;

          pp.entry();

          pp.enterpat();

          c1.enterdata(pp);

          c1.counterwork(pp);

          Doctor d1(pp);

          system("cls");

          int aa;

          for (int i = 0; i < 20; i++)

          {

                   system("cls");

                   cout << "Enter 1 to show Manu" << endl << endl;

                   cin >> aa;

                   if (aa == 1)

                   {

                             cout << "*******************************************" << endl;

                             int a;

                             cout << "Follow the instructions to check the details" << endl;

                             cout << "Press 1 to show the Quarentine center details" << endl;

                             cout << "Press 2 for all patients detail" << endl;

                             cout << "Press 3 to check specific patient health status" << endl;

                             cout << "Press 4 to check the doctor detail" << endl;

                             cout << "Press 5 to show total patients" << endl;

                             cout << "Press 6 if patient is dead" << endl;

                             cin >> a;

                             switch (a)

                             {

                             case 1:

                             {

                                                  q1.centerdetail();

                                                  break;

                             }

                             case 2:

                             {

                                                  c1.show_patiant(pp);

                                                  break;

                             }

                             case 3:

                             {

                                                  c1.check_health_status(pp);

                                                  break;

                             }

                             case 4:

                             {

                                                  d1.doctor_detail(pp);

                                                  break;

                             }

                             case 5:

                             {

                                                  c1.showcount();

                                                  break;

                             }

                             case 6:

                             {

                                                  c1.death();

                                                  break;

                             }

                             default:

                             {

                                                   cout << "Manu not found" << endl;

                             }

                             }

                   }

                   else

                   {

                             cout << "THank you for using" << endl;

                   }

          }

          getchar();

          getchar();

          return 0;

}

       
 

Comments

Popular posts from this blog

Multiple inheritance,friend function and multiple file in oop(object oriented programming)

Concepts of OOP (object oriented programming)

Concepts in c++........