C++ Assignment Doctor whose objects are records for a clinic doctors. Derive thi
ID: 3674403 • Letter: C
Question
C++ Assignment
Doctor whose objects are records for a clinic doctors. Derive this class from the class Person given in Doctor record has the doctor name defined in the class Person a specialty as a string (for example Pediatrician, Obstetrician, General Practitioner, and so on), and an office visit fee (use the type double). Give your class a reasonable complement of constructors and accessor methods, and an equals method as well. Further, define two classes: Patient and Billing, whose objects are records for a clinic. Derive Patient from the class Person given in . A Patient record has the patient name (defined in the class Person) and identification number (use the type String). A Billing object will contain a Patient object and a Doctor object. Give your classes a reasonable complement of constructors and accessor methods, and an equals method as well. Write a test program that creates at least two patients, at least two doctors, and at least two Billing records and then displays the total income from the Billing records
Please write out the code fully completed and being compile ready for visual studio. Thanks!
Explanation / Answer
Please find the required program below :
// Example program
#include <iostream>
#include <string>
using namespace std;
class Person
{
public:
void setName(string n)
{
name = n;
}
string getName()
{
return name;
}
protected:
string name;
};
// Derived class
class Doctor: public Person
{
public:
int getVisitfee()
{
return visitfee;
}
void setVisitfee(int f)
{
visitfee = f;
}
protected:
int visitfee;
};
class Patient: public Person
{
public:
string getId()
{
return id;
}
void setId(string i)
{
id = i;
}
protected:
string id;
};
class Billing
{
public:
void setDoctor(Doctor d)
{
doctor = d;
}
Doctor getDoctor()
{
return doctor;
}
void setPatient(Patient p)
{
patient = p;
}
Patient getPatient()
{
return patient;
}
protected:
Doctor doctor;
Patient patient;
};
int main()
{
Doctor d1,d2;
Patient p1,p2;
d1.setName("doctor 1");
d1.setVisitfee(300);
d2.setName("doctor 2");
d2.setVisitfee(400);
p1.setName("patient 1");
p1.setId("111");
p2.setName("patient 2");
p2.setId("115");
Billing b1,b2;
b1.setDoctor(d1);
b2.setDoctor(d2);
b1.setPatient(p1);
b2.setPatient(p2);
int total_income = b1.getDoctor().getVisitfee() + b1.getDoctor().getVisitfee();
cout << "Total income = " << total_income << endl;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.