Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Date.h"
- #include <iostream>
- using namespace std;
- //int main()
- Date::Date(int month,int day,int year)
- {
- this->month = month;
- this->day = day;
- this->year = year;
- }
- bool Date::setMonth (int month)
- {
- if (month>0 && month<=12)
- {
- this-> month= month;
- return true;
- }
- else
- {
- return false;
- }
- }
- bool Date::setYear(int year)
- {
- if (year>0)
- {
- this->year=year;
- return true;
- }
- else
- {
- return false;
- }
- }
- bool Date::setDay(int day)
- {
- if (day>0 && day<32)
- {
- this->day=day;
- return true;
- }
- else
- {
- return false;
- }
- }
- int Date::getMonth()
- {
- return month;
- }
- int Date::getYear()
- {
- return year;
- }
- int Date::getDay()
- {
- return day;
- }
- void Date::print(int type)
- {
- if (type==1)
- {
- cout<<month<<"/"<<day<<"/"<<year<<endl;
- }
- else if (type==2)
- {
- cout<<monthName[month-1]<<" "<<day<<","<<year<<endl;
- }
- else
- {
- cout<<day<<" "<<monthName[month-1]<<" "<<year<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement