Question
Given the files day.h and question2.cpp. The header provides the complete declaration for the Day class. Without modifying the declaration, complete the methods of the
Given the files day.h and question2.cpp. The header provides the complete declaration for the Day class. Without modifying the declaration, complete the methods of the class and use Question1.cpp to verify your implementation. The output should match the example below.
day.h file:
#include
using namespace std;
class Day {
public:
Day();
Day(string day);
void setDay(string day);
string getDay();
void addDays(int numDays);
string nextDay();
string prevDay();
private:
int getIdx(string day);
string getStr(int idx);
string _day;
};
question2.cpp:
#include
#include"Day.h"
using namespace std;
int main(void) {
Day dflt, thu("THU");
cout << "Default Constructor: " << dflt.getDay() << endl;
cout << "Thursday Constructor: " << thu.getDay() << endl;
thu.addDays(5);
cout << "Added 5 days to Thursday: " << thu.getDay() << endl;
cout << "Tomorrow is: " << thu.nextDay() << endl;
cout << "Yesterday was: " << thu.prevDay() << endl;
}
output Example:
Default Constructor: SUN
Thursday Constructor: THU
Added 5 days to Thursday: TUE
Tomorrow is: WED
Yesterday was: MON
Press any key to continue . . .
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started