C++結課報告(簡易日程管理系統)參考模板_第1頁
C++結課報告(簡易日程管理系統)參考模板_第2頁
C++結課報告(簡易日程管理系統)參考模板_第3頁
C++結課報告(簡易日程管理系統)參考模板_第4頁
C++結課報告(簡易日程管理系統)參考模板_第5頁
已閱讀5頁,還剩20頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論