Answer to Question #276841 in C++ for hari

Question #276841

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”. 



1
Expert's answer
2021-12-08T03:06:13-0500
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";
        }
    }
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment