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

下载本文档

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

文档简介

1、精选优质文档-倾情为你奉上C+程序设计报告基于命令Win32命令行应用程序的简易日程管理系统12010520033 徐益C+语言程序设计教师:黄鹏宇作者一、问题阐述日程管理就是将每天的工作和事务安排在日期中,并做一个有效的记录,方便管理日常的工作和事务,达到工作备忘的目的。同时也具有对员工日常工作进行指导、监督的作用。电子版的日程管理通常具有定时提醒和共享等功能。通过学习C+课程以及面向对象的程序设计,我发现日程管理中所需的日期、时间、记录等都可以抽象成类,并可以利用函数实现简单的添加、查询功能。由于能力的限制,本次“简易日程管理系统”的设计依旧基于Win32命令行应用程序(MFC好难啃),主

2、要实现的功能有:1、 输入日程;2、 查询全部日程;3、 查询单条日程;4、 修改时间。二、基本设计包括流程图、类关系图、文件关系图。1、流程图2、类关系图包含于包含于3、文件关系图三、源代码SIMPLESCHEDULESYSTEM.CPP#include "stdafx.h"#include<iostream>#include<fstream>#include"record.h"using namespace std;void menue();void addRecord();void getRecord();void chan

3、geToday();void getRecordAll();ofstream fout(RECORDPATH);Date today(2014, 12, 25);int main()while (true)menue();int n;cin >> n;switch (n)case 1: cout << "n" << endl; addRecord(); cout << "n" << endl; break;case 2: cout << "n" <<

4、endl; getRecordAll(); cout << "n" << endl; break;case 3: cout << "n" << endl; changeToday(); cout << "n" << endl; break;case 4: cout << "n" << endl; getRecord(); cout << "n" << endl; break;c

5、ase 0:return 0;default: cout << "n" << endl; cout << "输入错误"<<endl; cout << "n" << endl; break;cout << "按任意键继续"getchar();getchar();fout.close();return 0;void menue()cout << "*" << endl;cout <<

6、; "|*|" << endl;cout << "| |" << endl;cout << "| 简易日程管理系统 |" << endl;cout << "| |" << endl;cout << "| 1 : 输入日程 |" << endl;cout << "| |" << endl;cout << "| 2 : 全部日程

7、 |" << endl;cout << "| |" << endl;cout << "| 3 : 修改当前日期 |" << endl;cout << "| |" << endl;cout << "| 4 : 查询日程 |" << endl;cout << "| |" << endl;cout << "| 0 : 退出 |"

8、<< endl;cout << "| |" << endl;cout << "| |" << endl;cout << "|*|" << endl;cout << "*" << endl;cout << " " << endl;cout << "今天是" << today.getDate() << endl;c

9、out << " " << endl;cout << " " << endl;cout << "请选择:" << endl;cout << " " << endl;void addRecord()string date, s_time, e_time, content;char ch;int n;cout << "*" << endl;cout << "*

10、输入日程*" << endl;cout << "*" << endl;cout << "需输入的记录数:" << endl;cin >> n;for (int i = n; i > 0;i-)cout << "请输入日期(格式为*/*/*):" << endl;cin >> date;cout << "请输入开始时间(格式为*:*):" << endl;cin >

11、> s_time;cout << "请输入结束时间(格式为*:*):" << endl;cin >> e_time;cout << "请输入事件内容:" << endl;cin >> content;Record rec(date, s_time, e_time, content);cout << "*" << endl;cout << rec.getRecord() << endl;today.earlyDa

12、te(rec.getDate();cout << "*" << endl;cout << "是否确认?(y/n):" << endl;cin >> ch;if (ch = 'y') fout << rec.getRecord() << endl;cout << "*输入成功*" << 'n' << endl;else i+;/rec.Record();void getRecord()s

13、tring date_s;bool isFind = false;cout << "*" << endl;cout << "*查询日程*" << endl;cout << "*" << endl;cout << "请输入日期(格式为*/*/*):" << endl;cin >> date_s;cout << "*" << endl;Date date(date_s)

14、;ifstream fin(RECORDPATH);for (string str; getline(fin, str);)int y, m, d;char ch;istringstream sin(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.ear

15、lyDate(date);isFind = true;if (!isFind) cout << "没有记录" << endl;cout << "*" << endl;void getRecordAll()cout << "*" << endl;cout << "*全部日程*" << endl;cout << "*" << endl;ifstream fin(RECORDPATH

16、);for (string str; getline(fin, str);)cout << str << endl;cout << "*" << endl;void changeToday()string date;cout << "请输入日期(格式为*/*/*):" << endl;cin >> date;today.set(date);cout << "*设置成功*" << endl;MYDATE.H#ifndef MYDA

17、TE_H#define MYDATE_H#include <iostream>#include <iomanip>#include <stdlib.h>using namespace std;class Dateint year, month, day;public:void set(int y, int m, int d);void set(string s);Date()Date(int y, int m, int d);Date(string s);int getYear() return year; int getMonth() return mon

18、th; int getDay() return day; string getDate();bool isLeapYear()const;bool isLate(Date date);void print()const;void addDay(int n);int earlyDate(Date date);Date:Date(int y, int m, int d)year = y; month = m; day = d;/-Date:Date(string s)year = atoi(s.substr(0, 4).c_str();month = atoi(s.substr(5, 2).c_s

19、tr();day = atoi(s.substr(8, 2).c_str();/-void Date:set(int y, int m, int d)year = y; month = m; day = d;/-void Date:set(string s)year = atoi(s.substr(0, 4).c_str();month = atoi(s.substr(5, 2).c_str();day = atoi(s.substr(8, 2).c_str();/-inline bool Date:isLeapYear()constreturn (year % 4 = 0 &&

20、; year % 100 != 0) | (year % 400 = 0);/-inline void Date:print()constcout << setfill('0');cout << setw(4) << year << '/' << setw(2) << month << '/' << setw(2) << day << endl;cout << setfill(' ');/-void

21、Date:addDay(int n)for (int i = n; i > 0; i-)day+;switch (month)case 4:;case 6:;case 9:;case 11:if (day>30) day = 1; month+; break;case 12:if (day>31) day = 1; month = 1; year+; break;case 2:if (isLeapYear() && day>29) | day>28) day = 1; month+; break;default:if (day>31) day

22、 = 1; month+; break;/-string Date:getDate()stringstream ss;ss << setw(4) << setfill('0') << year << "/" << setw(2) << setfill('0') << month << "/" << setw(2) << setfill('0') << day;string st

23、r = ss.str();/ss.stringstream();return str;bool Date:isLate(Date date)if (year > date.year) return true;else if (year = date.year)if (month > date.month) return true;else if (month = date.month)if (day > date.day) return true;return false;int Date:earlyDate(Date date)if (isLate(date)cout &l

24、t;< "已过期" << endl;return -1;elseint i = 0;Date da(year,month,day);for (; date.isLate(da); i+)da.addDay(1);cout << "距今还有" << i << "天" << endl;#endifMYTIME.H#ifndef MYTIME_H#define MYTIME_H#include <iostream>#include <iomanip>#

25、include <stdlib.h>using namespace std;class Timeint hour, minute;public:Time()Time(int h, int m);Time(string s);void set(int h, int m);void set(string s);void print()const;string getTime();Time:Time(int h, int m)hour = h; minute = m;/-Time:Time(string s)hour = atoi(s.substr(0, 2).c_str();minut

26、e = atoi(s.substr(3, 2).c_str();/-void Time:set(int h, int m)hour = h; minute = m;/-void Time:set(string s)hour = atoi(s.substr(0, 2).c_str();minute = atoi(s.substr(3, 2).c_str();/-inline void Time:print()constcout << setfill('0');cout << setw(2) << hour << ':'

27、; << setw(2) << minute;cout << setfill(' ');/-string Time:getTime()stringstream ss;ss << setw(2) << setfill('0') << hour << ":" << setw(2) << setfill('0') << minute;string str = ss.str();/ss.stringstream();

28、return str;/-#endifRECORD.H#ifndef RECORD_H#define RECORD_H#include <iostream>#include <iomanip>#include <stdlib.h>#include <string>#include <sstream>#include "myDate.h"#include "myTime.h"#define RECORDPATH "record.txt"using namespace std;class RecordDate date;Time s_time;Time e_time;string content;public:Record(string da, string start, string end, string con);void input();void print();string getRecord();Date getDate() return date; ;Record

温馨提示

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

评论

0/150

提交评论