//This program is suppose to display the date for several date objects
//declared in the main function. But after running the program I realize.
//That it's incrementing the last month to 13. Im not sure why.
#include "stdafx.h"
#include<iostream>
#include<string>
#include<conio.h>
using namespace std;
class Date
{
private:
int month;
int day;
int year;
static string slash;
void setMonth(int);
void setDay(int, int);
void setYear(int);
public:
void IncreaseDay(int, int, int);
void setDate(int, int, int);
void showDate();
};
string Date::slash = "/";
void Date::setDate(int Mon, int Da, int Yea)
{
setMonth(Mon);
setDay(Da, Mon);
setYear(Yea);
IncreaseDay(Mon, Da, Yea);
}
void Date::setMonth(int Mon)
{
if(Mon > 12)
month = 12;
else
month = Mon;
}
void Date::setDay(int Da, int Mon)
{
if(Mon = 2 && Da < 29)
day = Da;
else
day = 28;
if((Mon = 1 || 3 || 5 ||7 ||9 || 10 || 12) && (Da < 32))
day = Da;
else
day = 31;
if((Mon = 4 || 6 || 8 || 11) && (Da < 31))
day = Da;
else
day = 30;
}
void Date::setYear(int Yea)
{
year = Yea;
}
void Date::IncreaseDay(int Mon, int Da, int Yea)
{
if((Mon = 2) && (Da > 28))
{
month++;
day = 1;
}
else
if((Mon = 1 || 3 || 5 || 7 || 9 || 10) && (Da >= 32))
{
month++;
day = 1;
}
else
if((Mon = 4 || 6 || 8 || 11) && (Da >= 31))
{
month++;
day = 1;
}
else
if((Mon >= 12) && (Da >= 32))
{
month = 1;
day = 1;
year++;
}
}
void Date::showDate()
{
cout << "Today's date is: " << month << slash << day << slash << year << endl;
}
int main()
{
Date date;
date.setDate(3, 6, 12);
date.showDate();
Date diffDate;
diffDate.setDate(5, 33, 13);
diffDate.showDate();
Date aDate;
aDate.setDate(5, 34, 14);
aDate.showDate();
Date newDate;
newDate.setDate(12, 29, 07);
newDate.showDate();
_getch();
return 0;
}