Starting from:
$30

$24

Lab 10 Solution

Objectives:




Learn about inheritance



Explore how to redefine the member functions of a base class



Learn about composition/aggregation









Download Lab10.cpp. In this file, the definition of the class personType has given. Think of the personType as the base class.




Question1 (Inheritance)




Derive the class doctorType, inherited from the class personType, with an additional class member variable member to store a doctor’s specialty(string type) Then, implement following class member function prototypes.



doctorType(string,string,string);//Firstname Lastname Specialty doctorType();//Default constructor




void setSpecialty(string);//Set doctor specialty




string getSpecialty()const;// Get doctor specialty




void print()const;//Display doctor information the same as given output format




Derive the class patientType, inherited from the class personType, with additional class member variables to store a patient’s id, age, and dob (all are integers). Then, implement following class member function prototypes.



patientType(string, string, int, int, int);//Firstname Lastname id age dob




patientType();Default constructor




void setId(int);//Set patient id




void setage(int);//Set patient age




void setDob(int);//Set patient DOB




int getId()const;//Get patient id




int getage()const;//Get patient




int getDob()const;//Get patient DOB




void print()const; //Display patient information the same as given output format

Question2 (Composition)




Design a class billType, with class member variables to store a patient’s information (patientType), the patient’s doctor’s information (doctorType), and the hospital charges(double). Then, implement following class member function prototypes.



billType(doctorType &d, patientType &p); // Constructor void setCharge(double);//Set hospital charges double getCharge()const;//Get hospital charges




void print()const;//Display a bill information the same as given output format




Use the provided driver program to test your program. You should get the same output.




Submit a single cpp file.







Output:







Write two programs in one single cpp file.

More products