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”.
class Patient {
private:
int patient_id, oxygen_level;
public:
Patient(int, int) {
this->patient_id = patient_id;
this->oxygen_level = oxygen_level;
}
int getPatientId() {
return this->patient_id;
}
int getOxygenLevel() {
return this->oxygen_level;
}
};
class Covid{
private:
char test;
public:
Covid(char) {
this->test = test;
}
char getTest() {
return this->test;
}
};
class Oxygen_Supply: public Covid, public Patient{
public:
void eligibility_supply() {
if (getTest() == 'p' && getOxygenLevel() < 90) {
cout << "Patient needs oxygen supply\n";
} else if (getTest() == 'n' && getOxygenLevel() < 90) {
cout << "Patient needs oxygen supply\n";
}
}
};
Comments
Leave a comment