Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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
{
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;
}
Person.h
#include
#include
#include
using namespace std;
class Person {
public:
Person();
Person(string first_name, string last_name, string mother_maiden_name, int ssn);
Person(const Person &obj);
void operator = (const Person &obj);
~Person();
string getFirstName();
string getLastName();
string getMotherMaidenName();
int getSSN();
static int getNum();
void setFirstName(string first_name);
void setLastName(string last_name);
void setMotherMaidenName(string mother_maiden_name);
void setSSN(int ssn);
friend ostream& operator
private:
string first_name;
string last_name;
string mother_maiden_name;
int ssn;
static int num;
};
Person.cpp
#include
#include
#include
#include"Person.h"
using namespace std;
Person::Person() {
this->first_name = "default";
this->ssn = 0;
num++;
}
Person::Person(string first_name, string last_name, string mother_maiden_name, int ssn) {
this->first_name = first_name;
this->last_name = last_name;
this->mother_maiden_name = mother_maiden_name;
this->ssn = ssn;
num++;
}
Person::Person(const Person &obj) {
this->first_name = obj.first_name;
this->last_name = obj.last_name;
this->mother_maiden_name = obj.mother_maiden_name;
this->ssn = obj.ssn;
num++;
}
void Person::operator = (const Person &obj) {
this->first_name = obj.first_name;
this->last_name = obj.last_name;
this->mother_maiden_name = obj.mother_maiden_name;
this->ssn = obj.ssn;
}
Person::~Person() {
num--;
}
string Person::getFirstName() {
return first_name;
}
string Person::getLastName() {
return last_name;
}
string Person::getMotherMaidenName() {
return mother_maiden_name;
}
int Person::getSSN() {
return ssn;
}
void Person::setFirstName(string first_name) {
this->first_name = first_name;
}
void Person::setLastName(string last_name) {
this->last_name = last_name;
}
void Person::setMotherMaidenName(string mother_maiden_name) {
this->mother_maiden_name;
}
void Person::setSSN(int ssn) {
this->ssn = ssn;
}
int Person::getNum() {
return num;
}
ostream& operator
os
os
os
os
return os;
}
int Person::num = 0;
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 with AI-Powered 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

Students also viewed these Databases questions