-
Notifications
You must be signed in to change notification settings - Fork 0
/
Date.cpp
45 lines (36 loc) · 807 Bytes
/
Date.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include "Date.h"
Date::Date(int day,int month,int year) : m_day(day), m_month(month), m_year(year){
}
void Date::setDay(int day){
if ( day > 0 && day < 32)
m_day = day;
else
std::cout<<"Error: day out of range (default value is 1) \n";
}
void Date::setMonth(int month){
if( month > 0 && month <13)
m_month = month;
else
std::cout<<"Error: month out of range (default value is 1) \n";
}
void Date::setYear(int year){
if ( year >= 2019)
m_year = year;
else
std::cout<<"Error: year out of range (default value is 2019)\n";
}
void Date::modifDate(int day, int month, int year){
setDay(day);
setMonth(month);
setYear(year);
}
int Date::getYear() const{
return m_year;
}
int Date::getMonth() const{
return m_month;
}
int Date::getDay() const{
return m_day;
}