Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Help Please!!!! I need to get a better understanding of this exercise. //The code I have #include #include #include #include int days[13]={0, 31, 28,

C++ Help Please!!!!

I need to get a better understanding of this exercise.

//The code I have

#include #include #include #include int days[13]={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

using namespace std; class Date{ private: int month; int day; int year; public:

/* Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400. */ bool isLeapYear(int y){ if (y % 4 != 0) { cout << "Common year" << endl; return false; }

else if (y % 100 != 0) { cout << "Leap year" << endl; return true; }

else if (y % 400 != 0) { cout << "Common year" << endl; return false; } else { cout << "Leap year" << endl; return true; } } /* verify if the ranges of month/m, day/d, year/y are correct. month should be 1-12 day should be based on its month and whether it is leap year. (Feb has 29 days for a leap year) year should be between 2000-2020 return false if in invalid range. otherwise return true. the upper bound of day/d of each month is given in the array days at line 21 */ bool checkRange(int m, int d, int y){ //add source code here... } //constructor of Date class Date(int m=1, int d=1, int y=2000) { /*call checkRange and see if m, d, y are within the range or not. if not, continue to request input from user until the ranges are valid. Assign m, d, y to month, day, year, respectively after validation. */ //add source code here... } int getMonth() { return month; } int getDay() { return day; } int getYear() { return year; } }; class Patient { private: string name; string ID; int age; char gender; //'M' or 'F' Date* admission_date; public: Patient(string name="", string ID="", int age=20, char gender='F', Date* date=nullptr){ this->name=name; this->ID = ID; this->age = age; this->gender = gender; admission_date=date; } ~Patient(){} string getName() { return name; } string getID() { return ID; } int getAge() { return age; } char getGender() { return gender; } Date* getAdmissionDate() { return admission_date; } /* Each patient has admission date. If the admission date is more than 10 days earlier than today, then it expires and returns true. Otherwise, it does not expire and returns false. */ bool isFreeAdmissionExpired(Date* today) { //add source code here... } }; class Hospital { private: vector ward; public: Hospital() {} void addPatient(Patient& p) { ward.push_back(&p); } /* pass in today's date. Remove those patients whose free admission have expired. */ void removeFreeAdmissionExpiredPatient(Date* today) { //add source code here... } void listAdmissionExpiredPatients(Date* today) { for (int i = 0; i < ward.size(); i++) { if (ward[i]->isFreeAdmissionExpired(today)) { cout<getName()<<" "<< ward[i]->getID()<getName()<<" "<getID()<& exp1, vector& exp2) { for (int i = 0; i < vec1.size(); ++i) { if (exp1.size() != exp2.at(exp2.size() - 1 - i)) { cout << "false"; return false; } else { cout << "true"; return true; } } } int main(int argc, const char * argv[]) { vector exp1={'a','b','b','a'}; vector exp2={'a','b','c','b','a'}; vector exp3={'a','b','c','a'}; cout<addPatient(*adam); hospital->addPatient(*alan); hospital->addPatient(*abbie); hospital->addPatient(*bob); hospital->addPatient(*cathy); hospital->addPatient(*david); hospital->addPatient(*eddie); hospital->listAllPatients(); hospital->listAdmissionExpiredPatients(date4); hospital->removeFreeAdmissionExpiredPatient(date4); hospital->listAllPatients(); return 0; }

//Give me a thourough explaination on what everything is doing please. Thank you

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

Contrast variables that increase helping and aggressive behavior.

Answered: 1 week ago