Write a program that contains a class that implements the days of the week.
Set the day
Print the day
Return the day
Return the next day
Return the previous day
Calculate and return the day by adding a certain amount of days to the current day. For example if you add 5 days to Saturday, the day to be returned is Thursday. Likewise, if we add 12 days to Wednesday, the the day returned will be Monday.
Ok, I wrote a code prior to this, here it is:
One question?
1.How do I implement mon=Monday, etc on the output of this code?
Also, I will try what my teacher is asking after I have corrected this code output.
Can I get any suggestions that can help me in the right directions.
Should I use a pointer to DayOfTheWeek::myDay?
And If there are any helpful hints, I would be much abligied.
#include <iostream>
#include <string>
using namespace std;
class DayOfTheWeek
{
public:
private:
string day; //Day of the week
public:
string Monday;
string Tuesday;
string Wednesday;
string Thursday;
string Friday;
string Saturday;
string Sunday;
string pointer;
DayOfTheWeek(void);
~DayOfTheWeek(void);
string getDay();
void setDay(string);
void printDay();
void myDay(void);
};
int main()
{
string DayOfWeek = "";
DayOfTheWeek myDay;
DayOfTheWeek DayOne;
DayOfTheWeek DayTwo;
DayOfWeek = DayOne.getDay();
DayOne.setDay(DayOfWeek);
DayOfWeek = DayTwo.getDay();
DayTwo.setDay(DayOfWeek);
DayOne.printDay();
DayTwo.printDay();
return 0;
}
void DayOfTheWeek::myDay()
{
const string mon = Monday;
const string tues = Tuesday;
const string weds = Wednesday;
const string thurs = Thursday;
const string fri = Friday;
const string sat = Saturday;
const string sun = Sunday;
}
DayOfTheWeek::DayOfTheWeek(void)
{
day = "default";
}
DayOfTheWeek::~DayOfTheWeek(void)
{
}
string DayOfTheWeek::getDay()
{
string tempDay;
cout << "Enter Day: ";
cin >> tempDay;
return tempDay;
}
void DayOfTheWeek::setDay(string DayOfWeek)
{
day = DayOfWeek;
}
void DayOfTheWeek::printDay()
{
cout << "The Day Is : " << day << endl;
Mod edit - Please
This post has been edited by BetaWar: 09 March 2009 - 03:16 PM

New Topic/Question
Reply




MultiQuote





|