C++结课报告简易日程管理系统_第1页
C++结课报告简易日程管理系统_第2页
C++结课报告简易日程管理系统_第3页
C++结课报告简易日程管理系统_第4页
C++结课报告简易日程管理系统_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

-.z.-----总结资料C++程序设计报告C++程序设计报告——基于命令Win32命令行应用程序的简易日程管理系统*益

C++语言程序设计

教师:黄鹏宇作者日程管理就是将每天的工作和事务安排在日期中,并做一个有效的记录,方便管理日常的工作和事务,到达工作备忘的目的。同时也具有对员工日常工作进展指导、监视的作用。电子版的日程管理通常具有定时提醒和共享等功能。通过学习C++课程以及面向对象的程序设计,我发现日程管理中所需的日期、时间、记录等都可以抽象成类,并可以利用函数实现简单的添加、查询功能。由于能力的限制,本次"简易日程管理系统〞的设计依旧基于Win32命令行应用程序〔MFC好难啃……〕,主要实现的功能有:输入日程;查询全部日程;查询单条日程;修改时间。包括流程图、类关系图、文件关系图。1、流程图2、类关系图包含于包含于包含于包含于3、文件关系图SimpleScheduleSystem.cpp#include"stdaf*.h"#include<iostream>#include<fstream>#include"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();cout<<"\n"<<endl;break;}case2:{cout<<"\n"<<endl;getRecordAll();cout<<"\n"<<endl;break;}case3:{cout<<"\n"<<endl;changeToday();cout<<"\n"<<endl;break;}case4:{cout<<"\n"<<endl;getRecord();cout<<"\n"<<endl;break;}case0:{return0;}default:{cout<<"\n"<<endl;cout<<"输入错误"<<endl;cout<<"\n"<<endl;break;}}cout<<"按任意键继续";getchar();getchar();fout.close();}return0;}voidmenue(){cout<<"**************************************************************"<<endl;cout<<"|************************************************************|"<<endl;cout<<"||"<<endl;cout<<"|简易日程管理系统|"<<endl;cout<<"||"<<endl;cout<<"|1:输入日程|"<<endl;cout<<"||"<<endl;cout<<"|2:全部日程|"<<endl;cout<<"||"<<endl;cout<<"|3:修改当前日期|"<<endl;cout<<"||"<<endl;cout<<"|4:查询日程|"<<endl;cout<<"||"<<endl;cout<<"|0:退出|"<<endl;cout<<"||"<<endl;cout<<"||"<<endl;cout<<"|************************************************************|"<<endl;cout<<"**************************************************************"<<endl;cout<<""<<endl;cout<<"今天是"<<today.getDate()<<endl;cout<<""<<endl;cout<<""<<endl;cout<<"请选择:"<<endl;cout<<""<<endl;}voidaddRecord(){stringdate,s_time,e_time,content;charch;intn;cout<<"****************************************************************"<<endl;cout<<"*************************输入日程*******************************"<<endl;cout<<"****************************************************************"<<endl;cout<<"需输入的记录数:"<<endl;cin>>n;for(inti=n;i>0;i--){cout<<"请输入日期〔格式为****/**/**〕:"<<endl;cin>>date;cout<<"请输入开场时间〔格式为**:**〕:"<<endl;cin>>s_time;cout<<"请输入完毕时间〔格式为**:**〕:"<<endl;cin>>e_time;cout<<"请输入事件内容:"<<endl;cin>>content;Recordrec(date,s_time,e_time,content);cout<<"****************************************************************"<<endl;cout<<rec.getRecord()<<endl;today.earlyDate(rec.getDate());cout<<"****************************************************************"<<endl;cout<<"是否确认?〔y/n):"<<endl;cin>>ch;if(ch=='y'){fout<<rec.getRecord()<<endl;cout<<"*************************输入成功*******************************"<<'\n'<<endl;}elsei++;// rec.~Record();}}voidgetRecord(){stringdate_s;boolisFind=false;cout<<"****************************************************************"<<endl;cout<<"*************************查询日程*******************************"<<endl;cout<<"****************************************************************"<<endl;cout<<"请输入日期〔格式为****/**/**〕:"<<endl;cin>>date_s;cout<<"**************************************************************"<<endl;Datedate(date_s);ifstreamfin(RECORDPATH);for(stringstr;getline(fin,str);){inty,m,d;charch;istringstreamsin(str);sin>>y;sin>>ch;sin>>m;sin>>ch;sin>>d;if(date.getYear()==y&&date.getMonth()==m&&date.getDay()==d){cout<<str<<endl;today.earlyDate(date);isFind=true;}}if(!isFind)cout<<"没有记录"<<endl;cout<<"**************************************************************"<<endl;}voidgetRecordAll(){cout<<"****************************************************************"<<endl;cout<<"*************************全部日程*******************************"<<endl;cout<<"****************************************************************"<<endl;ifstreamfin(RECORDPATH);for(stringstr;getline(fin,str);){cout<<str<<endl;cout<<"**************************************************************"<<endl;}}voidchangeToday(){stringdate;cout<<"请输入日期〔格式为****/**/**〕:"<<endl;cin>>date;today.set(date);cout<<"*************************设置成功*******************************"<<endl;}myDate.h#ifndefMYDATE_H#defineMYDATE_H#include<iostream>#include<iomanip>#include<stdlib.h>usingnamespacestd;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::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){year=y;month=m;day=d;}//------------------------------------------------voidDate::set(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());}//------------------------------------------------inlineboolDate::isLeapYear()const{return(year%4==0&&year%100!=0)||(year%400==0);}//------------------------------------------------inlinevoidDate::print()const{cout<<setfill('0');cout<<setw(4)<<year<<'/'<<setw(2)<<month<<'/'<<setw(2)<<day<<endl;cout<<setfill('');}//------------------------------------------------voidDate::addDay(intn){for(inti=n;i>0;i--){day++;switch(month){case4:;case6:;case9:;case11:if(day>30){day=1;month++;}break;case12:if(day>31){day=1;month=1;year++;}break;case2:if((isLeapYear()&&day>29)||day>28){day=1;month++;}break;default:if(day>31){day=1;month++;}break;}}}//------------------------------------------------stringDate::getDate(){stringstreamss;ss<<setw(4)<<setfill('0')<<year<<"/"<<setw(2)<<setfill('0')<<month<<"/"<<setw(2)<<setfill('0')<<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)){cout<<"已过期"<<endl;return-1;}else{inti=0;Dateda(year,month,day);for(;date.isLate(da);i++)da.addDay(1);cout<<"距今还有"<<i<<"天"<<endl;}}#endifmyTIME.h#ifndefMYTIME_H#defineMYTIME_H#include<iostream>#include<iomanip>#include<stdlib.h>usingnamespacestd;classTime{inthour,minute;public:Time(){}Time(inth,intm);Time(strings);voidset(inth,intm);voidset(strings);voidprint()const;stringgetTime();};Time::Time(inth,intm){hour=h;minute=m;}//------------------------------------------------Time::Time(strings){hour=atoi(s.substr(0,2).c_str());minute=atoi(s.substr(3,2).c_str());}//------------------------------------------------voidTime::set(inth,intm){hour=h;minute=m;}//------------------------------------------------voidTime::set(strings){hour=atoi(s.substr(0,2).c_str());minute=atoi(s.substr(3,2).c_str());}//------------------------------------------------inlinevoidTime::print()const{cout<<setfill('0');cout<<setw(2)<<hour<<':'<<setw(2)<<minute;cout<<setfill('');}//------------------------------------------------stringTime::getTime(){stringstreamss;ss<<setw(2)<<setfill('0')<<hour<<":"<<setw(2)<<setfill('0')<<minute;stringstr=ss.str();// ss.~stringstream();returnstr;}//------------------------------------------------#endifReCord.h#ifndefRECORD_H#defineRECORD_H#include<iostream>#include<iomanip>#include<stdlib.h>#include<string>#include<sstream>#include"myDate.h"#include"myTime.h"#defineRECORDPATH"record.t*t"usi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论