C++结课报告(简易日程管理系统)Word格式.docx
《C++结课报告(简易日程管理系统)Word格式.docx》由会员分享,可在线阅读,更多相关《C++结课报告(简易日程管理系统)Word格式.docx(21页珍藏版)》请在冰点文库上搜索。
record.h"
usingnamespacestd;
voidmenue();
voidaddRecord();
voidgetRecord();
voidchangeToday();
voidgetRecordAll();
ofstreamfout(RECORDPATH);
Datetoday(2014,12,25);
intmain()
{
while(true){
menue();
intn;
cin>
>
n;
switch(n){
case1:
{
cout<
<
"
\n"
<
endl;
addRecord();
break;
}
case2:
getRecordAll();
case3:
changeToday();
case4:
getRecord();
case0:
return0;
default:
cout<
输入错误"
endl;
break;
}
cout<
按任意键继续"
;
getchar();
fout.close();
}
return0;
}
voidmenue()
cout<
**************************************************************"
|************************************************************|"
||"
|简易日程管理系统|"
|1:
输入日程|"
|2:
全部日程|"
|3:
修改当前日期|"
|4:
查询日程|"
|0:
退出|"
"
今天是"
today.getDate()<
请选择:
"
voidaddRecord(){
stringdate,s_time,e_time,content;
charch;
intn;
****************************************************************"
*************************输入日程*******************************"
需输入的记录数:
cin>
for(inti=n;
i>
0;
i--){
请输入日期(格式为****/**/**):
date;
请输入开始时间(格式为**:
**):
s_time;
请输入结束时间(格式为**:
e_time;
请输入事件内容:
content;
Recordrec(date,s_time,e_time,content);
rec.getRecord()<
today.earlyDate(rec.getDate());
是否确认?
(y/n):
ch;
if(ch=='
y'
){
fout<
cout<
*************************输入成功*******************************"
'
\n'
elsei++;
// rec.~Record();
voidgetRecord(){
stringdate_s;
boolisFind=false;
*************************查询日程*******************************"
date_s;
Datedate(date_s);
ifstreamfin(RECORDPATH);
for(stringstr;
getline(fin,str);
){
inty,m,d;
charch;
istringstreamsin(str);
sin>
y;
m;
d;
if(date.getYear()==y&
&
date.getMonth()==m&
date.getDay()==d){
str<
today.earlyDate(date);
isFind=true;
if(!
isFind)cout<
没有记录"
voidgetRecordAll(){
*************************全部日程*******************************"
str<
voidchangeToday(){
stringdate;
today.set(date);
*************************设置成功*******************************"
MYDATE.H
#ifndefMYDATE_H
#defineMYDATE_H
#include<
iomanip>
stdlib.h>
classDate{
intyear,month,day;
public:
voidset(inty,intm,intd);
voidset(strings);
Date(){}
Date(inty,intm,intd);
Date(strings);
intgetYear(){returnyear;
}
intgetMonth(){returnmonth;
intgetDay(){returnday;
stringgetDate();
boolisLeapYear()const;
boolisLate(Datedate);
voidprint()const;
voidaddDay(intn);
intearlyDate(Datedate);
};
Date:
:
Date(inty,intm,intd){
year=y;
month=m;
day=d;
}//------------------------------------------------
Date(strings){
year=atoi(s.substr(0,4).c_str());
month=atoi(s.substr(5,2).c_str());
day=atoi(s.substr(8,2).c_str());
voidDate:
set(inty,intm,intd){
set(strings){
inlineboolDate:
isLeapYear()const{
return(year%4==0&
year%100!
=0)||(year%400==0);
inlinevoidDate:
print()const{
setfill('
0'
);
setw(4)<
year<
/'
setw
(2)<
month<
day<
addDay(intn){
i--){
day++;
switch(month){
case4:
case6:
case9:
case11:
if(day>
30){day=1;
month++;
}break;
case12:
31){day=1;
month=1;
year++;
case2:
if((isLeapYear()&
day>
29)||day>
28){day=1;
default:
stringDate:
getDate(){
stringstreamss;
ss<
)<
/"
day;
stringstr=ss.str();
// ss.~stringstream();
returnstr;
boolDate:
isLate(Datedate){
if(year>
date.year)returntrue;
elseif(year==date.year){
if(month>
date.month)returntrue;
elseif(month=date.month){
if(day>
date.day)returntrue;
returnfalse;
intDate:
earlyDate(Datedate){
if(isLate(date)){
已过期"
return-1;
else{
inti=0;
Dateda(year,month,day);
for(;
date.isLate(da);
i++)
da.addDay
(1);
距今还有"
i<
天"
#endif
MYTIME.H
#ifndefMYTIME_H
#defineMYTIME_H
classTime{
inthour,minute;
Time(){}
Time(inth,intm);
Time(strings);
voidset(inth,intm);
stringgetTime();
Time:
Time(inth,intm){
hour=h;
minute=m;
Time(strings){
hour=atoi(s.substr(0,2).c_str());
minute=atoi(s.substr(3,2).c_str());
voidTime:
set(inth,intm){
inlinevoidTime:
hour<
'
minute;
}//--------------------------------------------