In this exercise, 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, with an additional data member to store a doctor’s speciality. Add appropriate constructors and member func- tions to initialize, access, and manipulate the data members. 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 construc- tors and member functions to initialize, access, and manipulate the data members. c. Design the class patientType, inherited from the class personType, 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. d. Write a program to test your classes. Class personType is pictured b

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter13: Overloading And Templates
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question
100%

In this exercise, 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, with an additional data member to store a doctor’s speciality. Add appropriate constructors and member func- tions to initialize, access, and manipulate the data members.
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 construc- tors and member functions to initialize, access, and manipulate the data members.
c. Design the class patientType, inherited from the class personType, 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.
d. Write a program to test your classes.

Class personType is pictured below

17:51
l LTE O
A AA
745 of 1491
More Examples of Classes| 695
cout << "Line 14: The sum of the numbers rolled"
<< " by the dice is: "
<« diel.getNum ()
+ die2.getNum () << endl;
//Line 14
diel.roll ();
die2.roll () ;
//Line 15
//Line 16
cout << "Line 17: After again rolling, the sum of "
<< "the numbers rolled is:"
<« diel.getNum () + die2.getNum () << endl;
//Line 17
return 0;
}//end main
//Line 18
//Line 19
Sample Run:
Line 8: diel: 1
Line 9: die2: 1
Line 11: After rolling diel: 4
Line 13: After rolling die2: 3
Line 14: The sum of the numbers rolled by the dice is: 7
Line 17: After again rolling, the sum of the numbers rolled is: 8
The preceding program works as follows. The statements in Lines 6 and 7 create
the objects diel and die2, and using the default constructor set both dice to 1. The
statements in Lines 8 and 9 output the number of both dice. The statement in Line 10
rolls diel and the statement in Line 11 outputs the number rolled. Similarly, the
statement in Line 12 rolls die2 and the statement in Line 13 outputs the number
rolled. The statement in Line 14 outputs the sum of the numbers rolled by diel and
die2. The statements in Lines 15 and 16 again rolls both dice and the statement in
Line 17 outputs the sum of the numbers rolled.
1
The class personType that is designed in Example 10-10 is very useful; we will use
this class in subsequent chapters.
EXAMPLE 10-10
The most common attributes of a person are the person's first and last name. The
typical operations on a person's name are to set the name and print the name. The
following statements define a class with these properties.
#include <string>
using namespace std;
class personType
public:
void print 0 const;
//Function to output the first name and last name
//in the form firstName lastName.
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Transcribed Image Text:17:51 l LTE O A AA 745 of 1491 More Examples of Classes| 695 cout << "Line 14: The sum of the numbers rolled" << " by the dice is: " <« diel.getNum () + die2.getNum () << endl; //Line 14 diel.roll (); die2.roll () ; //Line 15 //Line 16 cout << "Line 17: After again rolling, the sum of " << "the numbers rolled is:" <« diel.getNum () + die2.getNum () << endl; //Line 17 return 0; }//end main //Line 18 //Line 19 Sample Run: Line 8: diel: 1 Line 9: die2: 1 Line 11: After rolling diel: 4 Line 13: After rolling die2: 3 Line 14: The sum of the numbers rolled by the dice is: 7 Line 17: After again rolling, the sum of the numbers rolled is: 8 The preceding program works as follows. The statements in Lines 6 and 7 create the objects diel and die2, and using the default constructor set both dice to 1. The statements in Lines 8 and 9 output the number of both dice. The statement in Line 10 rolls diel and the statement in Line 11 outputs the number rolled. Similarly, the statement in Line 12 rolls die2 and the statement in Line 13 outputs the number rolled. The statement in Line 14 outputs the sum of the numbers rolled by diel and die2. The statements in Lines 15 and 16 again rolls both dice and the statement in Line 17 outputs the sum of the numbers rolled. 1 The class personType that is designed in Example 10-10 is very useful; we will use this class in subsequent chapters. EXAMPLE 10-10 The most common attributes of a person are the person's first and last name. The typical operations on a person's name are to set the name and print the name. The following statements define a class with these properties. #include <string> using namespace std; class personType public: void print 0 const; //Function to output the first name and last name //in the form firstName lastName. Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
17:51
l LTE O
AA
746 of 1491
696 | Chapter 10: Classes and Data Abstraction
void setName (string first, string last) ;
//Function to set firstName and lastName according
//to the parameters.
//Postcondition: firstName = first; lastName = last
string getFirstName() const;
//Function to return the first name.
//Postcondition: The value of firstName is returned.
string getLastName () const;
//Function to return the last name.
//Postcondition: The value of lastName is returned.
personType (string first = ", string last = "");
//Constructor
//Sets firstName and lastName according to the parameters.
//The default values of the parameters are null strings.
//Postcondition: firstName = first; lastName = last
private:
string firstName; //variable to store the first name
string lastName;
};
//variable to store the last name
Figure 10-11 shows the UML class diagram of the class personType.
personType
-firstName: string
-las tName : string
+print (): void
+setName (string, string): void
+getFirstName () const: s tring
+getLas tName () const: string
+personType (string = "", string = "")
FIGURE 10-11 UML class diagram of the class personType
We now give the definitions of the member functions of the class personType.
void personType::print() const
{
cout << firstName << " " << lastName;
}
void personType::setName (string first, string last)
{
firstName = first;
lastName = last;
}
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
EBI
Transcribed Image Text:17:51 l LTE O AA 746 of 1491 696 | Chapter 10: Classes and Data Abstraction void setName (string first, string last) ; //Function to set firstName and lastName according //to the parameters. //Postcondition: firstName = first; lastName = last string getFirstName() const; //Function to return the first name. //Postcondition: The value of firstName is returned. string getLastName () const; //Function to return the last name. //Postcondition: The value of lastName is returned. personType (string first = ", string last = ""); //Constructor //Sets firstName and lastName according to the parameters. //The default values of the parameters are null strings. //Postcondition: firstName = first; lastName = last private: string firstName; //variable to store the first name string lastName; }; //variable to store the last name Figure 10-11 shows the UML class diagram of the class personType. personType -firstName: string -las tName : string +print (): void +setName (string, string): void +getFirstName () const: s tring +getLas tName () const: string +personType (string = "", string = "") FIGURE 10-11 UML class diagram of the class personType We now give the definitions of the member functions of the class personType. void personType::print() const { cout << firstName << " " << lastName; } void personType::setName (string first, string last) { firstName = first; lastName = last; } Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203 EBI
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning