Example defined a class personType to store the name of a person. The member functions that we included merely print the name and set the name of a person. Redefine the class personType so that, in addition to what the existing class does, you also can do the following:
a. Set the first name only.
b. Set the last name only.
c. Store and set the middle name.
d. Check whether a given first name is the same as the first name of this person.
e. Check whether a given last name is the same as the last name of this person.
Write the definitions of the member functions to implement the operations for this class. Also, write a program to test various operations on this class.
Programming Exercise
Write the definition of the class dayType that implements the day of the week in a program. The class dayType should store the day, such as Sunday for Sunday. The program should be able to perform the following operations on an object of type dayType :
a. Set the day.
b. Print the day.
c. Return the day.
d. Return the next day.
e. Return the previous day.
f. Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add 4 days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday.
g. Add the appropriate constructors.
Example
The most common attributes of a person are the person’s first name 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.
//************************************************************// Author: D.S. Malik//// class personType// This class specifies the members to implementaname.//************************************************************#includeusing namespace std;class personType{public:void print () const;//Functiontooutput the first name and last name //in the form firstName lastName.void setName(string first, string last);//Functiontoset firstName and lastName according to the //parameters.//Postcondition: firstName = first; lastName = laststring getFirstName () const;//Functiontoreturn the first name.//Postcondition: The value of firstNameisreturned.string getLastName () const;//Functiontoreturn the last name.//Postcondition: The value of lastNameisreturned.personType ();//Default constructor//Sets firstName and lastName to null strings.//Postcondition: firstName = &“ ”; lastName = &“ ”;personType(string first, string last);//Constructor with parameters.//Sets firstName and lastName according to the parameters.//Postcondition: firstName = first; lastName = last;private:string firstName; //variable to store the first namestring lastName; //variable to store the last name};
Figure shows the UML class diagram of the class personType.
FIGURE 1-9
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;}string personType::getFirstName () const {return firstName;}string personType::getLastName () const{return lastName;}//Default constructor personType::personType (){firstName = &“ ”;lastName = &“ ”;}//Constructor with parameters personType::personType(string first, string last){firstName = first;lastName = last;}
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.