Commit a7676e67 authored by Michael's avatar Michael

michael.davityan:exercise_03_15v2

parent 761af79c
......@@ -3,30 +3,29 @@
Date::Date(int day, int month, int year)
{
setMonthDay(day);
if (month < 1) {
setMonth(1);
std::cout << "Info 1: wrong month value.";
return;
}
if (month > 12) {
setMonth(1);
std::cout << "Info 1: wrong month value.";
return;
}
setDay(day);
setMonth(month);
setYear(year);
}
void
Date::setMonthDay(int day)
Date::setDay(int day)
{
monthDay_ = day;
day_ = day;
}
void
Date::setMonth(int month)
{
if (month < 1) {
std::cout << "Info 1: wrong month value.";
return;
}
if (month > 12) {
std::cout << "Info 1: wrong month value.";
return;
}
month_ = month;
}
......@@ -37,9 +36,9 @@ Date::setYear(int year)
}
int
Date::getMonthDay()
Date::getDay()
{
return monthDay_;
return day_;
}
int
......@@ -57,6 +56,6 @@ Date::getYear()
void
Date::displayDate()
{
std::cout << getMonthDay() << "/" << getMonth() << "/" << getYear() << std::endl;
std::cout << getDay() << "/" << getMonth() << "/" << getYear() << std::endl;
}
......@@ -2,16 +2,16 @@ class Date
{
public:
Date(int day, int month, int year);
void setMonthDay(int day);
void setDay(int day);
void setMonth(int month);
void setYear(int year);
int getMonthDay();
int getDay();
int getMonth();
int getYear();
void displayDate();
private:
int monthDay_;
int day_;
int month_;
int year_;
};
......
......@@ -4,18 +4,18 @@
int
main()
{
int userMonthDay;
int userDay;
int userMonth;
int userYear;
std::cout << "Insert month day: ";
std::cin >> userMonthDay;
std::cin >> userDay;
std::cout << "Insert month : ";
std::cin >> userMonth;
std::cout << "Insert year: ";
std::cin >> userYear;
Date userDate(userMonthDay, userMonth, userYear);
Date userDate(userDay, userMonth, userYear);
userDate.displayDate();
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment