Here is what I have. I am trying to add days to the days I already have. Not sure how to set it up. I want to enter a number and it add to tell what the day will be how would I set that up here is what I have:
Code:
#include <iostream>
using namespace std;
const char* dayNames[] =
{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
class Day
{
public:
Day() { dayNumber = 0; }
const char* getDay() { return dayNames[dayNumber]; }
const char* getNextDay() { return dayNames[(dayNumber+1) % 7]; }
const char* getPrevDay() { return dayNames[(dayNumber+7-1) % 7]; }
const char* getDayPlus( int n ) { return dayNames[(dayNumber+n) % 7]; }
void setDay( int n ) { dayNumber = n; normalize(); }
void printDay() { cout << dayNames[dayNumber]; }
private:
int dayNumber;
void normalize() { dayNumber = dayNumber % 7; }
};
int main()
{
Day d;
cout << "The (default) day is " << d.getDay() <<endl
<< "The next day is " << d.getNextDay() <<endl
<< "How many days do you want to add?" <<endl
<< "The day plus is " << d.getDayPlus() <<endl
<< "The prev day is " << d.getPrevDay() <<endl;
d.setDay(6);
cout << "After 'd.setDay(6)' ... the day now is " << d.getDay() <<endl
<< "The next day is " << d.getNextDay() <<endl
<< "The day plus is " << d.getDayPlus() <<endl
<< "The prev day is " << d.getPrevDay() <<endl;
d.setDay(3);
cout << "After 'd.setDay(3)' ... the day now is " << d.getDay() <<endl
<< "The next day is " << d.getNextDay() <<endl
<< "The day plus is " << d.getDayPlus() <<endl
<< "The prev day is " << d.getPrevDay() <<endl;
d.printDay();
cout << "\nPress 'Enter' to continue ... " << flush;
cin.get();