




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、C+程序设计报告基于命令Win32命令行应用程序的简易日程管理系统12010520033 徐益C+语言程序设计教师:黄鹏宇作者0 / 25一、问题阐述日程管理就是将每天的工作和事务安排在日期中,并做一个有效的记录,方便管理日常的工作和事务,达到工作备忘的目的。同时也具有对员工日常工作进行指导、监督的作用。电子版的日程管理通常具有定时提醒和共享等功能。通过学习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 changeToday
3、();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" << endl; g
4、etRecordAll(); cout << "n" << endl; break;case 3: cout << "n" << endl; changeToday(); cout << "n" << endl; break;case 4: cout << "n" << endl; getRecord(); cout << "n" << endl; break;case 0:r
5、eturn 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;cout <
9、;< " " << endl;cout << " " << endl;cout << "请选择:" << endl;cout << " " << endl;void addRecord()string date, s_time, e_time, content;char ch;int n;cout << "*" << endl;cout << "*输入日程*&q
10、uot; << endl;cout << "*" << endl;cout << "需输入的记录数:" << endl;cin >> n;for (int i = n; i > 0;i-)cout << "请输入日期(格式为*/*/*):" << endl;cin >> date;cout << "请输入开始时间(格式为*:*):" << endl;cin >> s_
11、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.earlyDate(rec.
12、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()string d
13、ate_s;bool isFind = false;cout << "*" << endl;cout << "*查询日程*" << endl;cout << "*" << endl;cout << "请输入日期(格式为*/*/*):" << endl;cin >> date_s;cout << "*" << endl;Date date(date_s);ifstre
14、am 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.earlyDate(
15、date);isFind = true;if (!isFind) cout << "没有记录" << endl;cout << "*" << endl;void getRecordAll()cout << "*" << endl;cout << "*全部日程*" << endl;cout << "*" << endl;ifstream fin(RECORDPATH);for (
16、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 MYDATE_H#de
17、fine 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 month; int
18、 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_str();da
19、y = 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 && year
20、% 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 Date:ad
21、dDay(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 = 1; m
22、onth+; break;/-string Date:getDate()stringstream ss;ss << setw(4) << setfill('0') << year << "/" << setw(2) << setfill('0') << month << "/" << setw(2) << setfill('0') << day;string str = ss.
23、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 <<
24、"已过期" << 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>#include
25、 <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();minute = ato
26、i(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、lt; 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();return
28、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:Re
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 执业医师考试备考阶段分阶段目标与任务推进的重要性试题及答案
- 2025年卫生资格考试高效备考案例分享试题及答案
- 护理管理与质量控制试题及答案
- 2025年主管护师考试核心内容试题及答案
- 2025年执业护士考试重点复习试题及答案
- 互联网对中国文化传播的影响试题及答案
- 行政管理中的社区参与试题及答案
- 经济法概论考前准备试题及答案
- 护理学相关技术发展试题及答案
- 中国茶文化介绍课件
- 临床试验伦理委员会伦理审查不同意见沟通的标准操作规程
- 白酒酿造工艺课件
- 雷霆传奇亲测-h5修改汇总
- 关节镜技术在骨科的应用
- 2023年版-肿瘤内科临床路径
- 《中国传统文化心理学》课件第五章 传统文化与心理治疗(修)
- Q∕GDW 11445-2015 国家电网公司管理信息系统安全基线要求
- java考试管理系统源代码开题报告外文翻译英文文献计001
- 人教版九年级历史中考【政治经济专题复习课件44张】(共44张)
- T∕CSEA 6-2018 锌镍合金电镀技术条件
- 湘教版初中地理会考重点图复习汇集
评论
0/150
提交评论