版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、博客文章管理系統(tǒng)一 需求分析本次課程設(shè)計需要實(shí)現(xiàn)的是博客文章管理系統(tǒng)。經(jīng)過初步研究調(diào)查,博客文章項目多種多樣,有小說、散文、詩歌等。各項研究的人員也是不同的,各項文章投入的內(nèi)容各有差異。所以初步設(shè)定文章的屬性有編號、文章名和文章類別等等。文章項目被不斷的研究出來,所以系統(tǒng)需要實(shí)現(xiàn)錄入與刪除功能。讀者對文章研究項目需要進(jìn)行選擇,系統(tǒng)必須相應(yīng)的實(shí)現(xiàn)查詢與排序的功能。最后,文章項目被確定以后,系統(tǒng)需要把數(shù)據(jù)從內(nèi)存中寫入硬盤,實(shí)現(xiàn)輸入輸出功能。系統(tǒng)簡單流程: 開始 退出刪除顯示保存修改查詢添加項目選擇博客文章管理系統(tǒng):1.理順和規(guī)范文章信息的查詢和數(shù)據(jù)保存。2.提供集成的信息系統(tǒng),實(shí)現(xiàn)業(yè)務(wù)數(shù)據(jù)和資料的
2、共享。3.由于數(shù)據(jù)的處理由系統(tǒng)自動完成,準(zhǔn)確性與及時性大大提高,分析手段更加規(guī)范和多樣,不但減輕了工作強(qiáng)度,還將促進(jìn)博客管理人員從繁瑣的事務(wù)處理中解放出來,用更多的時間研究文章的分類和更高效的管理,研究并運(yùn)用現(xiàn)代管理方法改進(jìn)博客文章信息管理,促進(jìn)現(xiàn)代管理方法在文章管理中的廣泛應(yīng)用。博客文章系統(tǒng)各功能模塊 :1、登記入錄函數(shù);2、輸出顯示函數(shù);3、保存數(shù)據(jù)函數(shù);4、刪除函數(shù);5修改函數(shù);6、查詢函數(shù)(內(nèi)分:按編號查詢、按發(fā)布日期查詢、按文章名查詢、退出查詢);7退出函數(shù)2 系統(tǒng)設(shè)計和實(shí)現(xiàn)a)系統(tǒng)研究項目類 系統(tǒng)研究項目類中,ID是文章編號,Name是文章名稱,Time是發(fā)布日期等等。研究項目整個
3、類中包含一個輸出函數(shù)。所有數(shù)據(jù)成員與函數(shù)成員均為公有類型。class cBlogarticle+ IDBUFSIZE:char/ 文章編號+ NameBUFSIZE:char/文章名稱+ TimeBUFSIZE:char/發(fā)布日期+ FunctionBUFSIZE:char/主要內(nèi)容+StayTime :int/有效期+Recommendedindex:double/推薦指數(shù)+ flay :bool/標(biāo)志+ cBlogarticle()/構(gòu)造函數(shù)初始化b)設(shè)定的界面 博客文章管理系統(tǒng) 1:文章信息添加 2:文章信息顯示 3:文章信息保存 4:文章信息刪除 5:文章信息修改 6:文章信息查詢 7
4、:退 出 系 統(tǒng) 你選擇c)關(guān)鍵代碼的分析(1) 讀取數(shù)據(jù)庫void ReadData(tList<cBlogarticle> *tListMedic)/讀取數(shù)據(jù)庫char bufBUFSIZE; ifstream ifile("Blogarticle.txt",ios_base:in);/創(chuàng)建一個輸出文件流對象if (!ifile) cerr << "讀取時打開文件出錯!" << endl; cBlogarticle Blogarticle;while(ifile.getline(buf,BUFSIZE) /遍歷文本
5、,讀取數(shù)據(jù)ifile.getline(buf,BUFSIZE);strcpy(Blogarticle.ID,buf);/讀取文章編號memset(buf,0,BUFSIZE);ifile.getline(buf,BUFSIZE);/讀取文章名strcpy(Blogarticle.Name,buf);memset(buf,0,BUFSIZE);ifile.getline(buf,BUFSIZE);/讀取發(fā)布日期strcpy(Blogarticle.Time,buf);memset(buf,0,BUFSIZE);ifile.getline(buf,BUFSIZE);/讀取類別strcpy(Blog
6、article.Style,buf);memset(buf,0,BUFSIZE);file.getline(buf,BUFSIZE);/讀取主要內(nèi)容strcpy(Blogarticle.Function,buf);memset(buf,0,BUFSIZE);ifile.getline(buf,BUFSIZE);/讀取有效期Blogarticle.StayTime=atoi(buf);memset(buf,0,BUFSIZE);ifile.getline(buf,BUFSIZE);/讀取推薦指數(shù)Blogarticle.Recommendedindex=atoi(buf);memset(buf,0
7、,BUFSIZE);Blogarticle.flag=true;tListMedic->Insert(Blogarticle);cout<<"讀取數(shù)據(jù)成功!nn"ifile.close();/關(guān)閉文件return;void Display(tList<cBlogarticle> *tListMedic) /顯示鏈表 cNode<cBlogarticle> *p;p=tListMedic->head->next;while(p) if(p->data.flag) cout<<"nn文章編號:&q
8、uot;<<(p->data).ID<<"t文章名:"<<(p->data).Name<<"ntt發(fā)布日期:"<<(p->data).Time<<"ntt類別:"<<(p->data).Style;cout<<"ntt主要內(nèi)容:"<<(p->data).Function<<"ntt有效期:"<<(p->data).StayTime
9、<<"ntt推薦指數(shù)"<<(p->data).Recommendedindex;p=p->next;cout<<endl;system("pause");system("cls");return;(2)添加文章函數(shù)void AddTheBlogarticle(tList<cBlogarticle> *tListMedic)/添加文章函數(shù) cin>>tempBlogarticle.Name;/讀入文章名cout<<"請輸入文章發(fā)布日期:&quo
10、t;cin>>tempBlogarticle.Time;/讀入發(fā)布日期cout<<"請輸入文章類別:"cin>>tempBlogarticle.Style;/讀入類別cout<<"請輸入文章主要內(nèi)容:"cin>>tempBlogarticle.Function;/讀入主要內(nèi)容cout<<"請輸入文章有效期:"cin>>tempBlogarticle.StayTime;/讀入有效期cout<<"請輸入推薦指數(shù)"cin>
11、;>tempBlogarticle.Recommendedindex;/讀入指數(shù)tempBlogarticle.flag=true;tListMedic->Insert(tempBlogarticle);cout<<"添加成功!n"system("pause");system("cls");(3) 保存數(shù)據(jù)void SaveData(tList<cBlogarticle> *tListMedic)/保存數(shù)據(jù)int i=0;ofstream ofile("Blogarticle.txt&qu
12、ot;,ios_base:out);/創(chuàng)建一個輸入文件流對象if (!ofile) cerr << "保存時打開文件出錯!" << endl; cNode<cBlogarticle> *p;p=tListMedic->head->next;while(p)/從內(nèi)存中讀取數(shù)據(jù),存到外盤if(p->data.flag) ofile<<"n"ofile<<(p->data).ID<<"n"ofile<<(p->data).Nam
13、e<<"n"ofile<<(p->data).Time<<"n"ofile<<(p->data).Style<<"n"ofile<<(p->data).Function<<"n"ofile<<(p->data).StayTime<<"n"ofile<<(p->data).Recommendedindex<<"n"p=
14、p->next;cout<<"保存數(shù)據(jù)成功!n"ofile.close();system("pause");system("cls");return;(4) 查詢函數(shù)void FindTheBlogarticleById(tList<cBlogarticle> *tListMedic)/根據(jù)文章編號查找文章char idBUFSIZE;cout<<"n請輸入你要查找的文章編號:"cin>>id;/讀取文章編號bool flag=false; cNode<c
15、Blogarticle> *p;p=tListMedic->head->next;while(p)if(strcmp(p->data.ID,id)=0 && p->data.flag)flag=true;break;p=p->next;if(flag=false) cout<<"對不起,沒有你所查找的文章!n"/如果找不到else /如果找到了/顯示屏幕cout<<"n找到了,該文章的信息是:n"cout<<"nn文章編號:"<<(p-
16、>data).ID<<"t文章名:"<<(p->data).Name<<"ntt發(fā)布日期:"<<(p->data).Time<<"ntt類別:"<<(p->data).Style;cout<<"ntt主要內(nèi)容:"<<(p->data).Function<<"ntt有效期:"<<(p->data).StayTime<<"n
17、tt推薦指數(shù)"<<(p->data).Recommendedindex; cout<<endl;system("pause");system("cls");return;(5) 查找文章void FindTheBlogarticle(tList<cBlogarticle> *tListMedic)/查找文章system("cls");while(1)cout<<"nnnn"cout<<" 1:按文章編號查詢nn"cout
18、<<" 2:按文章名查詢nn"cout<<" 3:按類別查詢nn"cout<<" 4:退出查詢nn"cout<<"你選擇:"int choose=0;cin>>choose;switch(choose)/根據(jù)用戶選擇case 1:FindTheBlogarticleById(tListMedic);/按文章編號查詢break;case 2:FindTheBlogarticleByName(tListMedic);/按文章名查詢break;case 3:Fi
19、ndTheBlogarticleByStyle(tListMedic); /按類別查詢break;case 4:system("cls");return;/退出查詢default:break;return;(6)修改文章信息void ModifyTheBlogarticle(tList<cBlogarticle> *tListMedic)/修改文章信息char idBUFSIZE;cout<<"n請輸入你要查找的文章編號:"cin>>id;/讀取文章編號bool flag=false; cNode<cBlogar
20、ticle> *p;p=tListMedic->head->next;while(p)if(strcmp(p->data.ID,id)=0 && p->data.flag)flag=true;break;p=p->next;if(flag=false) cout<<"對不起,沒有你所查找的文章!n"/如果找不到else /如果找到了/顯示屏幕cout<<"找到了,該文章的原始信息是:n"cout<<"nn文章編號:"<<(p->d
21、ata).ID<<"t文章名:"<<(p->data).Name<<"ntt發(fā)布日期:"<<(p->data).Time<<"ntt類別:"<<(p->data).Style;cout<<"ntt主要內(nèi)容:"<<(p->data).Function<<"ntt有效期:"<<(p->data).StayTime<<"ntt推薦指
22、數(shù)"<<(p->data).Recommendedindex;cout<<"n下面開始修改該文章的信息:n"cBlogarticle tempBlogarticle; /定義臨時文章cout<<"請輸入文章文章編號:"cin>>tempBlogarticle.ID;/讀入文章編號cout<<"請輸入文章文章名:"cin>>tempBlogarticle.Name;/讀入文章名cout<<"請輸入發(fā)布日期:"cin&g
23、t;>tempBlogarticle.Time;/讀入發(fā)布日期cout<<"請輸入文章類別:"cin>>tempBlogarticle.Style;/讀入類別cout<<"請輸入文章主要內(nèi)容:"cin>>tempBlogarticle.Function;/讀入主要內(nèi)容cout<<"請輸入文章有效期:"cin>>tempBlogarticle.StayTime;/讀入有效期cout<<"請輸入推薦指數(shù):"cin>>t
24、empBlogarticle.Recommendedindex;/讀入指數(shù)tempBlogarticle.flag=true;p->data=tempBlogarticle;cout<<"修改成功!" cout<<endl;system("pause");system("cls");return;(7)刪除文章信息void DeleteTheBlogarticle(tList<cBlogarticle> *tListMedic)/刪除文章信息char idBUFSIZE;cout<<
25、;"n請輸入你要查找的文章編號:"cin>>id;/讀取文章編號bool flag=false;int count=0; cNode<cBlogarticle> *p;p=tListMedic->head->next;while(p)if(strcmp(p->data.ID,id)=0 && p->data.flag)count+;flag=true;break;p=p->nextif(flag=false) cout<<"對不起,沒有你所查找的文章!n"/如果找不到els
26、e /如果找到了 count-;cout<<"找到了,該文章的原始信息是:n"cout<<"nn文章編號:"<<(p->data).ID<<"t文章名:"<<(p->data).Name<<"ntt發(fā)布日期:"<<(p->data).Time<<"ntt類別:"<<(p->data).Style;cout<<"ntt主要內(nèi)容:"<
27、;<(p->data).Function<<"ntt有效期:"<<(p->data).StayTime<<"ntt推薦指數(shù)"<<(p->data).Recommendedindex;cout<<endl;(p->data).flag=false;cout<<"該文章的信息刪除成功!n" cout<<endl;system("pause");system("cls");return;(
28、8)主函數(shù)int main() tList<cBlogarticle> tListMedic;tListMedic.Create(); /創(chuàng)建鏈表ReadData(&tListMedic);while(1) cout<<"nn 博 客 文 章 管 理 系 統(tǒng) nn"cout<<" -nn"cout<<" 1:文章信息添加nn"cout<<" 2:文章信息顯示nn"cout<<" 3:文章信息保存nn"cout<
29、<" 4:文章信息刪除nn"cout<<" 5:文章信息修改nn"cout<<" 6:文章信息查詢nn"cout<<" 7:退 出 系 統(tǒng) nn"cout<<"你選擇:"int choose=0;scanf("%d",&choose);switch(choose)/根據(jù)用戶選擇case 1:AddTheBlogarticle(&tListMedic);/文章基本信息錄入break;case 2:Displa
30、y(&tListMedic);/文章基本信息顯示break;case 3:SaveData(&tListMedic); /文章基本信息保存break;case 4:DeleteTheBlogarticle(&tListMedic);/文章基本信息刪除break;case 5:ModifyTheBlogarticle(&tListMedic);/文章基本信息修改break;case 6:FindTheBlogarticle(&tListMedic);/文章基本信息查詢break;case 7:exit(0);/退出default:break;return 0; 調(diào)試編譯成功后開始運(yùn)行,信息錄入后,不能在文檔中正確可見,經(jīng)Debug調(diào)試,發(fā)現(xiàn),打開文件方式出現(xiàn)錯誤,改之,運(yùn)行正確。改動后的代碼: cout<<"請輸入文章類別:"cin>>tempBlogarticle.Style;/讀入類別cout<<"請輸入文章主要內(nèi)容:"cin>>tempBlogarticle.Function;/讀入主要內(nèi)容cout<<"請輸入文章有效期:"cin>>tempBlogarticle.StayTime;/
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 廈門房屋租賃合同樣本
- 房地產(chǎn)典當(dāng)合同
- 滬牌租賃合同多
- 石灰石購銷合同
- 居間合同協(xié)議書范本
- 酒吧的勞動合同
- 火焰探測器的種類和應(yīng)用
- 基于LabVIEW的鐵路彈條扣壓力測量系統(tǒng)設(shè)計
- 無償合同的題
- VTE預(yù)防相關(guān)護(hù)理管理制度
- 電力系統(tǒng)動態(tài)仿真與建模
- 中國的古代祭祀文化
- 學(xué)校中層干部管理培訓(xùn)
- 《航運(yùn)市場營銷》課件-海運(yùn)巨頭馬士基
- 繪本創(chuàng)作方案
- 《童年的水墨畫》的說課課件
- 地鐵保潔服務(wù)投標(biāo)方案(技術(shù)標(biāo))
- 2023年河南省新鄉(xiāng)市鳳泉區(qū)事業(yè)單位招聘53人高頻考點(diǎn)題庫(共500題含答案解析)模擬練習(xí)試卷
- 2023年小升初簡歷下載
- 廣府文化的奇葩
- 公路工程標(biāo)準(zhǔn)施工招標(biāo)文件(2018年版)解析
評論
0/150
提交評論