Q1. Design an application for hospital management system. For this, create the following classes
and members.
Person - name, date of birth, sex
Doctor - Specialization
Patient- Casenumber, Disease, date of admission, date of discharge, bill number.
Write function to input the data from the user and display data to the user.
#include <iostream>
#include <string>
using namespace std;
class Person
{
string name;
string date_of_birth;
char sex;
public:
Person(){}
void InputData()
{
cout << "\nPlease, enter a name of person: ";
cin >> name;
cout << "Please, enter date of birth of person: ";
cin >> date_of_birth;
cout << "Please, enter a sex of person [M/W]: ";
cin >> sex;
}
void Display()
{
cout << "\nInfo about person:"
<< "\nName: " << name
<< "\nDate of birth: " << date_of_birth
<< "\nSex: " << sex;
}
};
class Doctor:public Person
{
string special;
public:
Doctor():Person(){}
void InputDocData()
{
InputData();
cout << "Please, enter a special of doctor: ";
cin >> special;
}
void DisplayDoctor()
{
Display();
cout << "\nDoctor`s specialization: " << special;
}
};
class Patient:public Person
{
int caseNum;
string disease;
string date_of_admis;
string date_of_disch;
int billNum;
public:
Patient():Person(){}
void InputPatData()
{
InputData();
cout << "Please, enter a case number of person: ";
cin >> caseNum;
cout << "Please, enter a disease of person: ";
cin >> disease;
cout << "Please, enter date of adminsssion of person: ";
cin >> date_of_admis;
cout << "Please, enter date of discharge of person: ";
cin >> date_of_disch;
cout << "Please, enter bill number of person: ";
cin >> billNum;
}
void DisplayPat()
{
Display();
cout << "\nCase number: " << caseNum
<< "\nDisease: " << disease
<< "\nDate of admission: " << date_of_admis
<< "\nDate of discharge: " << date_of_disch
<< "\nBill number: " << billNum;
}
};
int main()
{
Doctor d;
d.InputDocData();
d.DisplayDoctor();
Patient p;
p.InputPatData();
p.DisplayPat();
}
Comments
Thanks.Very helpful.
Leave a comment