Create a class “patient” with data members Patient_id and Oxygen_level.
Create another class “covid” with character data member “test” (this can take value either ’p’ or ‘n’). Data members of both the classes should be initialized using constructor.
Class “oxygen_supply” is inherited from both the above classes. Include member function eligibility_supply which checks whether a patient needs oxygen supply or not.
If the patient has tested to positive(‘p’) and Oxygen_level is below 90, then print “patient needs oxygen supply”.
If the patient has tested to negative(‘n’) and Oxygen_level is below 90, then print “patient needs oxygen supply”.
Create an object of the derived class. When you create an object of the derived class, you need to initialize data members of both the parent classes. After creating the object, check the eligibility with the function eligibility_supply. Print output with appropriate messages.
#include <iostream>
using namespace std;
const int LEN = 80;
class Patient
{
public:
char Patient_id[LEN];
char Oxygen_level;
public:
void getdata()
{
cout<<"\nEnter Patient ID : ";
cin>>Patient_id;
cout<<"\nEnter Patient Oxygen level : ";
cin>>Oxygen_level;
}
void showdata()
{
cout<<"\nPatient ID : "<<Patient_id;
cout<<"\nOxygen Level : "<<Oxygen_level;
}
};
class Covid
{
public:
char test ;
public:
void getdata()
{
cout<<"\nEnter Test result (Use p for positive and n for negavive) : ";
cin>>test;
}
void showdata()
{
cout<<"\nTest result is : "<<test;
}
};
class Amount
{
private:
int dues;
public:
void getdata()
{
cout<<"Enter Dues of Patient : ";
cin>>dues;
}
void showdata()
{
cout<<"\nTotal Dues of Patient : "<<dues;
}
};
class Oxygen_supply: public Patient, public Covid
{
public:
void oxygen_eligibility()
{
if(test == 'p' && Oxygen_level<90 ){
cout<<"Patient needs oxygen";
}
else {
cout<<"Patient needs oxygen";
}
}
};
int main()
{
Patient p1;
cout<<"\nEnter Data ";
p1.getdata();
cout<<"\nInserted Data is : \n";
p1.showdata();
p1.oxygen_eligibility();
return 0;
}
Comments
Leave a comment