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”.
#include <iostream>
class patient
{
int Patient_id;
double Oxygen_level;
public:
patient(int id, double ox): Patient_id(id), Oxygen_level(ox){}
const double& get_oxygen_level()
{
return this->Oxygen_level;
}
};
class covid
{
char test;
public:
covid(char t):test(t){}
const char& get_test()
{
return this->test;
}
};
class oxygen_supply: public patient, public covid
{
public:
void eligibility_supply()
{
if(this->patient::get_oxygen_level() > 90 && this->covid::get_test() == 'p')
{
std::cout<<"patient needs oxygen supply"<<std::endl;
}
}
};
Comments
Leave a comment