Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this project, you will design various classes and write a program to computer

ID: 3882642 • Letter: I

Question

In this project, you will design various classes and write a program to computerize the billing system of a hospital.

a. Design the class doctorType, inherited from the class personType, defined in Chapter 10, with an additional data member to store a doctor’s speciality. Here is the UML diagram for this class:

b.    Design the class billType with data members to store a patient’s ID and a patient’s hospital charges, such as pharmacy charges for medicine, doctor’s fee, and room charges. Add appropriate constructors and member functions to initialize, access, and manipulate the data members. Here is the UML diagram for this class:

c. Design the class patientType, inherited from the class personType, defined in Chapter 10, with additional data members to store a patient’s ID, age, date of birth, attending physician’s name, the date when the patient was admitted in the hospital, and the date when the patient was discharged from the hospital. (Use the class dateType to store the date of birth, admit date, discharge date, and the class doctorType to store the attending physician’s name.) Add appropriate constructors and member functions to initialize, access, and manipulate the data members. Here is the UML diagram for this class:

Write a program to test your classes:

Create a patientType object and a billType object for that patient using the constructors and passing parameters with initial values to them.. Use the print functions from both objects to display the patient's information and charges.

Create a different patientType object using the default constructor. Use the setter and getter member functions to set and display the patient's information.

Create a third patientType object using the constructor with parameters, but pass it a bad date.

Here is an example of what the output should look like:

Turn in all your .h files, all your implementation files, and your test program. Make sure your header files are properly documented. Also turn in one or more screen shots showing the results of your testing.

Once this project is completed, you will demonstrate that you can

Utilize inheritance and composition in designing classes

Utilize polymorphism by overriding base class functions

Distinguish between accessing the members of a derived class from accessing the members of an aggregate class

Distinguish between applying the constructor for a derived class and applying the constructor of an aggregate class

Explanation / Answer

header files
#ifndef PERSONTYPE_H
#define PERSONTYPE_H

class PersonType
{
public:
void print() const;
void SetName(string first, string last);
string getFirstName() const;
string getLastName() const;
PersonType(string first, string last);
PersonType();//default constructor

private:
string FirstName, LastName;
};

#endif


#ifndef DOCTORTYPE_H
#define DOCTORTYPE_H

class DoctorType : public PersonType
{
public:
void SetSpeciality(string Special);
string getSpeciality() const;
DoctorType(string FirstName,string LastName,string Special);
DoctorType();//default constructor

private:
string Speciality;
};

#endif

#ifndef DATETYPE_H
#define DATETYPE_H

class DateType
{
public:
DateType(){}
void printDate() const;
void SetDate(int Day, int Month, int Year);
int getTheDay() const;
int getTheMonth() const;
int getTheYear() const;
DateType(int Day,int Month, int Year);

private:
int TheDay, TheYear, TheMonth;
};

#endif


#ifndef DATEOFBIRTHTYPE_H
#define DATEOFBIRTHTYPE_H
class DateOfBirthType : public DateType
{
public:
DateOfBirthType(){}
void printDOB() const;
void SetDOB(int Day, int Month, int Year);
int getTheDay() const;
int getTheMonth() const;
int getTheYear() const;

private:
int TheDay, TheYear, TheMonth;
};

#endif

#ifndef ADMITTANCETYPE_H
#define ADMITTANCETYPE_H
class AdmittanceDateType : public DateType
{
public:
AdmittanceDateType(){}
void printAdmittanceDate() const;
void SetAdmittanceDate(int Day, int Month, int Year);
int getTheDay() const;
int getTheMonth() const;
int getTheYear() const;

private:
int TheDay, TheYear, TheMonth;
};

#endif


#ifndef DISCHARGEDATETYPE_H
#define DISCHARGETYPE_H
class DischargeDateType : public DateType
{
public:
DischargeDateType(){}
void printDischargeDate() const;
void SetDischargeDate(int Day, int Month, int Year);
int getTheDay() const;
int getTheMonth() const;
int getTheYear() const;

private:
int TheDay, TheYear, TheMonth;
};

#endif


#ifndef BILLTYPE_H
#define BILLTYPE_H
class BillType
{
private :
double medicineCharge;
double doctorFee;
double roomCharges;

public:
BillType(double mCharge,double dFee,double rCharges);

void printBill();

};
#endif


#ifndef PATIENTTYPE_H
#define PATIENTTYPE_H
class PatientType : public PersonType
{
public:
void print() const;
void SetPatientID(int ID);
void SetPatientAge(int Age);
int getPatientAge() const;
int getPatientID() const;

PatientType(string FirstName,string LastName,int ID,int Age);
PatientType();//default constructor

private:
int PatientID, PatientAge;
};

#endif

cpp file

#include <iostream>
#include <cstring>
#include "PersonType.h"
#include "DoctorType.h"
#include "DateType.h"
#include "DateOfBirthType.h"
#include "AdmittanceType.h"
#include "DischargeDateType.h"
#include "BillType.h"
#include "PatientType.h"


using namespace std;


void PersonType :: print() const
{
cout << FirstName << " " << LastName << endl;
}
void PersonType :: SetName(string first, string last)
{
FirstName = first;
LastName = last;

}
string PersonType :: getFirstName() const
{
return FirstName;
}
string PersonType :: getLastName() const
{
return LastName;
}
PersonType :: PersonType(string first, string last)
{
FirstName = first;
LastName = last;
}
PersonType :: PersonType()
{
FirstName = " ";
LastName = " ";
}


void DoctorType :: SetSpeciality(string Special)
{
Speciality = Special;

}
string DoctorType :: getSpeciality() const
{
return Speciality;
}

//passing arguments to base class constructor
DoctorType :: DoctorType(string FirstName,string LastName,string
Special):PersonType(FirstName,LastName)
{
Speciality = Special;
}
DoctorType :: DoctorType()
{
Speciality = " ";
}


void DateType :: printDate() const
{
cout << TheDay << " " << TheMonth << " " << TheYear << endl;
}
void DateType :: SetDate(int Day, int Month, int Year)
{
TheDay = Day;
TheMonth = Month;
TheYear = Year;


}
int DateType :: getTheDay() const
{
return TheDay;
}
int DateType :: getTheMonth() const
{
return TheMonth;
}
int DateType :: getTheYear() const
{
return TheYear;
}
DateType::DateType(int Day, int Month, int Year)
{
TheDay = Day;
TheMonth = Month;
TheYear = Year;
}


void DateOfBirthType :: printDOB() const
{
cout << "Patients Date Of Birth: " << TheDay << "/" << TheMonth <<
"/" << TheYear << endl;
}
void DateOfBirthType :: SetDOB(int Day, int Month, int Year)
{
TheDay = Day;
TheMonth = Month;
TheYear = Year;

}


void AdmittanceDateType :: printAdmittanceDate() const
{
cout << "The Patients Admittance Date: " << TheDay << " " <<
TheMonth << " " << TheYear << endl;
}
void AdmittanceDateType :: SetAdmittanceDate(int Day, int Month, int Year)
{
TheDay = Day;
TheMonth = Month;
TheYear = Year;


}


void DischargeDateType :: printDischargeDate() const
{
cout << "The Patients Discharge Date: " << TheDay << " " <<
TheMonth << " " << TheYear << endl;
}
void DischargeDateType :: SetDischargeDate(int Day, int Month, int Year)
{
TheDay = Day;
TheMonth = Month;
TheYear = Year;


}

BillType::BillType(double mCharge,double dFee,double rCharges)
{
medicineCharge = mCharge;
doctorFee = dFee;
roomCharges = rCharges;
}
void BillType::printBill()
{
cout<<" Total Bill : $"<<(medicineCharge+doctorFee+roomCharges);
}
};


int PatientType::getPatientID() const
{
return PatientID;
}
int PatientType::getPatientAge() const
{
return PatientAge;
}
//passing arguments to base class constructor
PatientType::PatientType(string FirstName,string LastName,int ID,int
age):PersonType(FirstName,LastName)
{
PatientID = ID;
PatientAge = age;
}
PatientType::PatientType()
{
PatientID = 0;
PatientAge = 0;
}
int main()
{
int choice,age,pID,day,month,year,aDay,aMonth,aYear,dDay,dMonth,dYear;
string fname,lname,speciality;
double mcharge,dfee,rcharges;

cout << "Who would you like to input information for? ";
cout << " 1 - Doctor ";
cout << " 2 - Patient ";
cin >> choice;

if (choice == 1)
{
cout<<" Enter doctor first name :";
cin>>fname;
cout<<" Enter doctor last name :";
cin>>lname;
cout<<"Enter speciality : ";
cin>>speciality;
DoctorType d(fname,lname,speciality);
cout<<"Doctor : "<<d.getFirstName()<<" "<<d.getLastName()<<"
Speciality : "<<d.getSpeciality();
}
else if (choice == 2)
{
cout<<" Enter patient first name : ";
cin>>fname;
cout<<" Enter patient last name :";
cin>>lname;
cout<<" Enter patient's age : ";
cin>>age;
cout<<" Enter patientID : ";
cin>>pID;

cout<<" Enter day of birth of patient : ";
cin>>day>>month,year;

cout << "Enter The Patients DAY Of Admittance. ";
cin >> aDay;
cout << "Enter The Patients MONTH Of Admittance. ";
cin >> aMonth;
cout << "Enter The Patients YEAR Of Admittance. ";
cin >> aYear;
cout << "Enter The Patients DAY Of Discharge. ";
cin >> dDay;
cout << "Enter The Patients MONTH Of Discharge. ";
cin >> dMonth;
cout << "Enter The Patients YEAR Of Discharge. ";
cin >> dYear;

cout<<" Enter medicine charges ,doctor fee and room charges :";
cin>>mcharge>>dfee>>rcharges;
PatientType p(fname,lname,pID,age);
cout<<"Patient :"<<p.getFirstName()<<" "<<p.getLastName()<<" ID
:"<<p.getPatientID()<<" Age : "<<p.getPatientAge();

DateOfBirthType d;
d.SetDOB(day,month,year);
d.printDOB();

AdmittanceDateType adt;
adt.SetAdmittanceDate(aDay,aMonth,aYear);
adt.printAdmittanceDate();

DischargeDateType ddt;
ddt.SetDischargeDate(dDay,dMonth,dYear);
ddt.printDischargeDate();

BillType bt(mcharge,dfee,rcharges);
bt.printBill();
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote