Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have to write two classes, date and event. The Date class will use integers to

ID: 3622352 • Letter: I

Question

I have to write two classes, date and event. The Date class will use integers to store the day, month, and year. For example, it might be used like this to keep track of the date for Thanksgiving in 2010, and New Years Eve 2010.


Date *thanksgiving2010 = new Date(25, 11, 2010);
Date *newYearsEve2010 = new Date(31, 12, 2010);

The Event class uses date objects to represent the start and end of a multi-day event. Here is a line that constructs an event to represent the holiday season in 2010.

Event *holidays2010(thanksgiving2010, newYearsEve2010, “holiday season”);

Here are the classes public member functions, constructors, and class functions:

Date Class
Date(int day, int month, int year);

int getDay();
void setDay(int value);

int getMonth();
void setMonth(int value);

int getYear();
void setYear(int value);

static bool isLeapYear(int year);
static int daysInMonth(int month, int year);


Event Class
Event(Date *start, Date end, const char *title);

Date *getStartDate();
void setStartDate(Date *start);

Date *getEndDate();
void setEndDate(Date *start);

int eventDurationInDays();

the Date class has two static member functions. For the isLeapYear you should see if the year is evenly divisible by 4, but not by 1000. For the daysInMonth function, it was suggested that I give my Date class a static pointer to an array of 12 integers. Each element in the array should represent the days in the corresponding month. As well I am trying to experiment with making the Event class a friend of the Date class.

I have to submit five files: Date.h, Date.cpp, Event.h, Event.cpp, and testProgram.cpp. I really need help writing this so If any of this does not make sense please message me!! Thank you so much! Any help is greatly appreciated!

Explanation / Answer

Dear, Date class code #include using namespace std; //Date.h class Date { private: int day; int month; int year; public: //Constructor Date(int d,int m,int y) { day=d; month=m; year=y; } //Member function declarations //Mutator Functions void setDay(int ); void setMonth(int); void setYear(int); //Accessor Functions int getDay(); int getMonth(); int getYear(); //Print functions to print in different formats void printFormat1(); static bool isLeapYear(int year); static int daysInMonth(int month,int year); }; //Date.cpp bool Date:: isLeapYear(int year) { if( year%4==0) return true; else return false; } int Date::daysInMonth(int month,int year) { switch (month) { case 4: case 6: case 9: case 11: return 30; break; case 2: if (isLeapYear(year)) { return 29; } else return 28; break; default: return 31; break; } } //Member function definitions void Date::setDay(int d) { //Input validation if(d31) { coutd; }//end if day=d; }//end setDay void Date::setMonth(int m) { //Input validation if(m12) { coutm; }//end if month=m; }//end setMonth void Date::setYear(int y) { year=y; }//end setYear int Date::getDay() { return day; }//end getDay int Date::getMonth() { return month; }//end getMonth int Date::getYear() { return year; }//end getYear void Date::printFormat1() { cout