Below are two functions, the first function, Show, is used to display dates. The following function is used to control the format with which they are displayed. My issues is that Show comes along in the main program before Setformat, so I need a way for the program to know to use the default format(being 3) unless otherwise noted. Can anyone spare some advice?
void Date::Show()//Prints date based on format
{
switch(format)
{
case 1: cout << TWODIGIT[month] << '/' << TWODIGIT[day] << '/' << (year%100) << endl;//Prints out Two-Digit date
break;
case 2: cout << MONTH[month]<< day << ',' << year << endl;//Prints out Long date
break;
case 3: cout << month << '/' << day << '/' << year << endl;//Prints out Default Date format
break;
}
}
bool Date::SetFormat(char f)// Asks user what format they want, stores value in memory
{
bool formatSucess = true;
switch(toupper(f))
{
case'T': format = 1;
break;
case'L': format = 2;
break;
case'D': format = 3;
break;
default : cout << "You picked something wrong, so we're just gonna set to default. *pats on head*";
format = 3;
formatSucess = false;//User entered input incorrectly, thus the function returns false.
}
return formatSucess;
}