Answer to Question #276839 in C++ for hari

Question #276839

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-07T20:57:59-0500
#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;
        }
    }
};

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