Write a program that contains a class that implements the days of the week. The program should be able to perform the following on an object of the class.
1. Set the day.
2. Print the day.
3. Return the day.
4. Return the next day.
5. Return the previous day.
6. Calculate and return the day by adding a certain amount of days to the current day. For example, if you add five days to Saturday, the day to be returned is Thursday. Likewise, if we add 12 days to Wednesday, the day returned will be Monday.
#include <iostream>
#include <string>
using namespace std;
class DayOfTheWeek
{
public:
void setDay(string );
void printDay() const;
// printDay() prints the value of the day attribute
string getDay() const;
// returns the value of the day attribute.
private:
string day; // This is where the value of the day attribute is stored.
};
//////////////////Set the values of the objects
monday.setDay("Monday");
tuesday.setDay("Tuesday");
///////////////// value of the "monday" object and prints to screen
string currentDay = monday.getDay();
cout << "The value of the monday object is " << currentDay << "." << endl;
//////////////// value of the "tuesday" object and prints to screen
cout << "The value of the tuesday object is ";
tuesday.printDay();
cout << "." << endl;;
Well, it looks like you need to add functions to do these:
4. Return the next day.
5. Return the previous day.
6. Calculate and return the day by adding a certain amount of days to the current day. For example, if you add five days to Saturday, the day to be returned is Thursday. Likewise, if we add 12 days to Wednesday, the day returned will be Monday.