Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Person.h #include using namespace std; class Person { private: string *first_name; string *last_name; string *mother_maiden_name; int *ssn; static int num; public: Person(); Person(string firstname, string

image text in transcribed
Person.h
#include
using namespace std;
class Person {
private:
string *first_name;
string *last_name;
string *mother_maiden_name;
int *ssn;
static int num;
public:
Person();
Person(string firstname, string lastname, string mothermaidenname, int sssn);
Person(const Person &person);
Person operator=(const Person &other);
~Person();
int getssn();
void setssn(int ssssn);
string getfirstname();
void setfirstname(string firstname);
string getlastname();
void setlastname(string lastname);
string getmaidenname();
void setmaidname(string mothermaidenname);
static int getInstanceNum();
};
Person.cpp
#include
#include"Person.h"
using namespace std;
Person::Person() {
first_name = new string;
*first_name = "";
last_name = new string;
*last_name = "";
mother_maiden_name = new string;
*mother_maiden_name = "";
ssn = new int;
*ssn = 0;
num++;
}
Person::Person(string firstName, string lastname, string mothermaidenname, int sssn) {
first_name = new string;
*first_name = firstName;
last_name = new string;
*last_name = lastname;
mother_maiden_name = new string;
*mother_maiden_name = mothermaidenname;
ssn = new int;
*ssn = sssn;
num++;
}
Person::Person(const Person &person) {
first_name = new string;
*first_name = *person.first_name;
last_name = new string;
*last_name = *person.last_name;
mother_maiden_name = new string;
*mother_maiden_name = *person.mother_maiden_name;
ssn = new int;
*ssn = *person.ssn;
num++;
}
Person Person::operator=(const Person &other) {
first_name = other.first_name;
last_name = other.last_name;
mother_maiden_name = other.mother_maiden_name;
ssn = other.ssn;
return *this;
}
Person::~Person() {
num--;
}
int Person::getssn() {
return *ssn;
}
void Person::setssn(int ssssn) {
*ssn = ssssn;
}
string Person::getfirstname() {
return *first_name;
}
void Person::setfirstname(string firstname) {
*first_name = firstname;
}
string Person::getlastname() {
return *last_name;
}
void Person::setlastname(string lastname) {
*last_name = lastname;
}
string Person::getmaidenname() {
return *mother_maiden_name;
}
void Person::setmaidname(string mothermaidenname) {
*mother_maiden_name = mothermaidenname;
}
int Person::getInstanceNum() {
return num;
}
int Person::num = 0;
Date.h
#include
using namespace std;
class Date
{
private:
int month;
int date;
int year;
public:
Date();
Date(int d, int m, int y);
void check_date(int d, int m, int y);
string set_date()const;
friend ostream& operator
int getdate()const;
void setdate(int day);
int getmonth()const;
void setmonth(int mon);
int getyear()const;
void setyear(int nian);
};
Date.cpp
#include
#include"Date.h"
#include
using namespace std;
Date::Date()
{
}
Date::Date(int d, int m, int y) {
this->date = d;
this->month = m;
this->year = y;
check_date(d, m, y);
}
void Date::check_date(int d, int m, int y) {
int months[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
while (true)
{
if (m >= 1 && m
{
this->month = m;
break;
}
else
{
cout
cin >> m;
continue;
}
}
while (true)
{
if (d 0)
{
this->date = d;
break;
}
else
{
cout
cin >> d;
continue;
}
}
while (true)
{
if (y >= 1 && y
{
this->year = y;
break;
}
else
{
cout
cin >> y;
continue;
}
}
}
string Date::set_date()const
{
string months[] = { "January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December" };
return months[month - 1];
}
ostream& operator
dout
return dout;
}
int Date::getdate()const {
return date;
}
void Date::setdate(int day) {
this->date = day;
}
int Date::getmonth() const {
return month;
}
void Date::setmonth(int mon) {
this->month = mon;
}
int Date::getyear() const {
return year;
}
void Date::setyear(int nian) {
this->year = nian;
}
Change the person to fit the question a and create class doctortype and class patienttype and create a main.
a- (io pts) Design the class doctorType, inherited from the class Person (that you wrote in Prelab 5 but assume that all strings are not pointers, i.e. string f name; etc) with an additional string data member to store a doctor's specialty. Add appropriate constructors andmember functions to initialize, print, access and manipulate the data members. b- (i0 pts) Design class patientType, inherited from the class Person with additional data members to store a patient's ID, age, date of birth, and attending physician's name (Use the class Date you created in part 1) to store the date of birth. Note that patientType has-a doctorType as a member and doesn't inherit from it. Add appropriate constructors and memberfunctions to initialize access, print, and manipulate the data members. c- (1o pts) Add to class patientType the date when the patient was admitted in the hospital, and the date when the patient was discharged from the hospital (Use the class Date class) to store admit date, discharge date. Modify constructors nd add memberfunctions to initialize access, and manipulate the new added data members. d- (6 pts) Create a Print () function in Person and override it in both sub-classes Testing your program: (6 pts) In main), create a vector of pointers to type Person. Create three Date objects. One of the dates should be Date di(-1,43,2020). Test your check function to see if it works. Fill the vector up with at least three objects. One of Person, one of doctorType and one of patient Type using the three valid dates you created earlier Print all the data of the three objects of the vector. Make sure each object is printed according to its print function using the overridden Print ( )

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions

Question

4. Choose appropriate and powerful language

Answered: 1 week ago

Question

2. Choose an appropriate organizational pattern for your speech

Answered: 1 week ago