Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design various classes and write a program to comperterize the billing system of a hospital. Design the class doctorType, inherited from the class personType, with

Design various classes and write a program to comperterize the billing system of a hospital. Design the class doctorType, inherited from the class personType, with an additional data member to store a doctor's speciality. Add appropriate constructors and member functions to initialize, access, and manipulate the data members.

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.

Design the class patientType, inherited from the class personType, with additional data members to store the 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 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. Write a program to test your classes. (class personType and class dateType follow)

class personType {

public:

void print() const;

void setName(string first, string last);

string getFirstName() const;

string getLastName() const;

personType(string first = "", string last = "");

private:

string firstName;

string lastName;

};

void personType::print() const {

cout << firstName << " " << lastName; }

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; }

class dateType {

public:

void setDate(int month, int day, int year);

int getDay() const;

int getMonth() const;

int getYear() const;

void printDate() const;

dateType(int month = 1, int day = 1, int year = 1900);

private:

int dMonth;

int dDay;

int dYear;

};

void dateType::setDate(int month, int day, int year) {

dMonth = month;

dDay = day;

dYear = year; }

int dateType::getDay() const {

return dDay; }

int dateType::getMonth() const {

return dMonth; }

int dateType::getYear() const {

return dYear; }

void dateType::printDate() const {

cout << dMonth << "-" << dDay << "-" << dYear; }

dateType::dateType(int month, int day, int year) {

dMonth = month;

dDay = day;

dYear = year; } Example code follows: (This code only displays preset data for name, id & age for a patient; or name & specialty for a doctor. The program should ask for input for patient & doctor. Patient input/output should be first and last name, id, age, dob, hospital charges (pharmacy, doctor & room), physician's name, admittance date, and discharge date. Doctor output is correct, but should be based on user input, not preset.)

#include #include

using namespace std;

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; }; 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 = " "; }

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; }; 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 = " "; }

class DateType { public: 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; }; void DateType :: printDate() const { cout << TheDay << " " << TheMonth << " " << TheYear << endl; } void DateType :: SetDate(int Day, int Month, int Year) { TheDay = Day; TheMonth = Month; TheYear = Year; cout << "Please Enter The Day (DD). "; cin >> Day; cout << "Please Enter The Month (MM). "; cin >> Month; cout << "Please Enter The Year (YYYY). "; cin >> 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; }

class DateOfBirthType : public DateType { public: 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; }; 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;

cout << "Enter The Patients DAY Of Birth. "; cin >> Day; cout << "Enter The Patients MONTH Of Birth. "; cin >> Month; cout << "Enter The Patients YEAR Of Birth. "; cin >> Year; }

class AdmittanceDateType : public DateType { public: 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; }; 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;

cout << "Enter The Patients DAY Of Admittance. "; cin >> Day; cout << "Enter The Patients MONTH Of Admittance. "; cin >> Month; cout << "Enter The Patients YEAR Of Admittance. "; cin >> Year; }

class DischargeDateType : public DateType { public: 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; }; 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;

cout << "Enter The Patients DAY Of Discharge. "; cin >> Day; cout << "Enter The Patients MONTH Of Discharge. "; cin >> Month; cout << "Enter The Patients YEAR Of Discharge. "; cin >> Year; }

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; }; 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;

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

if (choice == 1) { DoctorType d("Joseph","Anderson","Neurologist"); cout<<"Doctor : "<

system("PAUSE"); return 0; }

Output:

Who would you like to input information for 1 - Doctor 2 - Patient 1 Doctor : Joseph Anderson Speciality : Neurologist This code only displays preset data for name, id & age for a patient; or name & specialty for a doctor. The program should ask for input for patient & doctor. Patient input/output should be first and last name, id, age, dob, hospital charges (pharmacy, doctor & room), physician's name, admittance date, and discharge date. Doctor output is correct, but should be based on user input, not preset.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions