From ff229452f15140df22ef699499d204277071a514 Mon Sep 17 00:00:00 2001 From: 201816040230 <56499333+201816040230@users.noreply.github.com> Date: Thu, 31 Oct 2019 23:11:19 +0800 Subject: [PATCH] Create Date.cpp This is my assignment_03 Student ID: 201816040230 --- 201816040230/Ex03_15/Date.cpp | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 201816040230/Ex03_15/Date.cpp diff --git a/201816040230/Ex03_15/Date.cpp b/201816040230/Ex03_15/Date.cpp new file mode 100644 index 0000000..5421f9f --- /dev/null +++ b/201816040230/Ex03_15/Date.cpp @@ -0,0 +1,40 @@ +#include +#include "Date.h" +using namespace std; +Date::Date(int month1,int day1,int year1)//构造函数初始化 +{ + setMonth(month1); + setDay(day1); + setYear(year1); +} +void Date::setMonth(int month2)//月的set函数 + { + month=month2; + } +int Date::getMonth()//月的get函数 +{ + if(month<1||month>12)//如果月不在1到12内则输出1 + return 1; + return month; +} + void Date::setDay(int day2)//日的set函数 + { + day=day2; + } +int Date::getDay()//日的get函数 + { + return day; + } +void Date::setYear(int year2)//年的set函数 +{ + year=year2; +} + +int Date::getYear()//年的get函数 +{ + return year; +} +void Date::displayDate()//输出显示数据 +{ + cout<<"月"<<"/"<<"日"<<"/"<<"年: "<