-
Notifications
You must be signed in to change notification settings - Fork 0
/
hospital_database.cpp
92 lines (83 loc) · 2.01 KB
/
hospital_database.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <iostream>
using namespace std;
struct date {
int d;
int m;
int y;
};
class Hospital
{
char name[100];
struct date d_adm;
struct date d_dis;
protected:
int age;
public:
void getdata()
{
cout << "Enter name of the patient: ";
cin >> name;
cout << "Enter age: ";
cin >> age;
cout << "Enter date of admission (day month year):\n";
cin >> d_adm.d >> d_adm.m >> d_adm.y;
cout << "Enter date of discharge (day month year): \n";
cin >> d_dis.d >> d_dis.m >> d_dis.y;
}
void display()
{
cout << name<<"\t\t";
cout << age<<"\t\t";
cout << d_adm.d << '-' << d_adm.m << '-' << d_adm.y<< "\t\t";
cout << d_dis.d << '-' << d_dis.m << '-' << d_dis.y<<"\t\t"<<endl;
}
};
class PediatricPatient : public Hospital
{
public:
char vaccine[20];
void get()
{
getdata();
cout << "Enter the name of the vaccine to be given: ";
cin >> vaccine;
}
void put()
{
if (age < 12) {
display();
cout << vaccine;
cout << "\n";
} else {
cout << "Age greater than 12, not a pediatric patient\n";
}
}
};
int main()
{
Hospital h[5];
int n;
cout << "Enter the number of patients: ";
cin >> n;
for (int i = 0; i < n; i++) {
h[i].getdata();
}
cout << "\nPatient database:\n";
cout << "NAME" << "\t" << "AGE" << "\t" << "DATE OF ADMISSION" << "\t" << "DATE OF DISCHARGE\n";
for (int i = 0; i < n; i++) {
h[i].display();
cout << "\n";
}
PediatricPatient a1[5];
cout << "\nEnter the number of pediatric patients: ";
cin >> n;
for (int i = 0; i < n; i++) {
a1[i].get();
}
cout << "\nPediatric Patient database:\n";
cout << "NAME" << "\t" << "AGE" << "\t" << "DATE OF ADMISSION" << "\t" << "DATE OF DISCHARGE" << "\t" << "VACCINE\n";
for (int i = 0; i < n; i++) {
a1[i].put();
}
return 0;
}