




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、一、 課程設(shè)計(jì)問題描述學(xué)院教學(xué)信息管理系統(tǒng)是高等學(xué)校教務(wù)管理的重要組成部分,其內(nèi)容較多,為了簡化計(jì)論,要求設(shè)計(jì)的管理系統(tǒng)能夠完成以下功能:(1)輸入:輸入每一位教師記錄,將其信息寫入文件中;(2)顯示:顯示每位教師記錄;(3)排序:按職工號或教學(xué)效果綜合評分進(jìn)行排序,并顯示;(4)查找:完成按姓名或課程查找教師的相關(guān)記錄,并顯示;(5)創(chuàng)建:創(chuàng)建新的紀(jì)錄,輸入數(shù)位教師記錄,顯示在屏幕上并保存;二、 課程設(shè)計(jì)目的和要求:經(jīng)過一個(gè)學(xué)期的C+面向?qū)ο髮?shí)用教程課程的學(xué)習(xí),已經(jīng)有了一定地程序設(shè)計(jì)基礎(chǔ),但是要學(xué)好C+程序設(shè)計(jì),不僅要認(rèn)真閱讀課本知識和從事課堂學(xué)習(xí),更重要的是要進(jìn)行上機(jī)實(shí)踐,通過上機(jī)實(shí)踐才能
2、增強(qiáng)和鞏固知識。三、 系統(tǒng)設(shè)計(jì)(算法分析)1、 整體結(jié)構(gòu)整個(gè)程序定義四個(gè)類(1) CPerson類:包含數(shù)據(jù)成員name,age,sex,記錄姓名,年齡,性別這些信息,并包含構(gòu)造函數(shù)及其他成員函數(shù)(定義CPerson類以后若有需要,可再通過繼承派生其他類);(2) CTeacher:共有繼承CPerson類,包含數(shù)據(jù)成員title,teano,course,score,分別記錄職稱,職工號,3門課程和教學(xué)效果綜合評分等信息,另有其他成員函數(shù);(3) CNode類:節(jié)點(diǎn)類,包含2個(gè)數(shù)據(jù)成員,CTeacher類對象p和CNode類指針對象next,作為構(gòu)建鏈表的單位;(4) CList類:鏈表類,
3、聲明為CNode類的友元類,數(shù)據(jù)成員有頭結(jié)點(diǎn)head,尾節(jié)點(diǎn)tail,記錄當(dāng)前節(jié)點(diǎn)的p和當(dāng)前節(jié)點(diǎn)前一節(jié)點(diǎn)的pre,鏈表相關(guān)的輸入,顯示,排序,查找,創(chuàng)建全部設(shè)為成員函數(shù)??傮w流程為先打開文件,讀取文件中的記錄來創(chuàng)建鏈表,然后對鏈表進(jìn)行操作,最后保存至文件中2、流程圖開始打開文件讀取記錄輸入choicechoice=0? 是 否查找排序創(chuàng)建新紀(jì)錄添加記錄顯示當(dāng)前記錄保存 是保存 否結(jié)束3、 各函數(shù)的功能和實(shí)現(xiàn)學(xué)院教學(xué)信息管理系統(tǒng)的相關(guān)功能由對應(yīng)的函數(shù)來實(shí)現(xiàn)。(1) 輸入教師信息并顯示void Append()通過提示一步步輸入信息,由程序構(gòu)建新節(jié)點(diǎn)并加入鏈表(2) 顯示所有記錄void Prin
4、t()(3)按職工號或教學(xué)效果綜合評分排序并顯示int SortMenu()void SortMenuControl()void InsertByTeano(CNode *newp)void SortByTeano()void InsertByScore(CNode *newp)void SortByScore()(4)按姓名或課程查找教師記錄并顯示int SearchMenu()void SearchMenuControl()void SearchByName()void SearchByCourse()四、程序源代碼#include stdafx.h#include #include #i
5、nclude #include #include #include using namespace std;class CPersonprivate:string name;int age;char sex;public:CPerson()CPerson(string name,int age=0,char sex=M)this-name=name;this-age=age;this-sex=sex;void SetAge(int age=0)this-age=age;void SetNameAndSex(string name,char sex)this-name=name;this-sex
6、=sex;void ShowInfo()coutnametaget(sex=M?男:女)endl;string GetName()return name;int GetAge()return age;char GetSex()return sex;class CTeacher:public CPersonprivate:string title;/職稱string teano;/職工號vector course;/教授課程float score;/教學(xué)效果綜合評分public:CTeacher()CTeacher(string name,int age=0,char sex=M):CPerso
7、n(name,age,sex)void SetData(string title,string teano)this-title=title;this-teano=teano;void SetCourse(string c1,string c2,string c3)course.push_back(c1);course.push_back(c2);course.push_back(c3);void SetScore(float score)this-score=score;void ShowInfo()coutteanotGetName()tGetAge()t(GetSex()=M?男:)ti
8、tletcourse0tcourse1tcourse2tscoretitle=one.title;this-teano=one.teano;this-course0=one.course0;this-course1=one.course1;this-course2=one.course2;this-score=one.score;vector GetCourse()return course;string GetTitle()return title;string GetTeano()return teano;float GetScore()return score;class CNodefr
9、iend class CList;private:CTeacher data;CNode *next;class CListprivate:CNode *head;CNode *tail;CNode *p;CNode *pre;int num;/當(dāng)前節(jié)點(diǎn)數(shù)public:int MainMenu()cout1.顯示當(dāng)前記錄endl;cout2.添加記錄endl;cout3.排序endl;cout4.查找endl;cout5.創(chuàng)建新紀(jì)錄endl;cout0.退出endl;coutchoice;return choice;void MainMenuControl()ReadData();while
10、( 1 )int choice=MainMenu();if ( choice=0 )break;switch ( choice )case 1:Print();break;case 2:Append();break;case 3:SortMenuControl();break;case 4:SearchMenuControl();break;case 5:NewList();break;coutc;if ( c=y )Save();void ReadData()head=tail=new CNode;head-next=NULL;num=0;char fname80;coutfname;ifs
11、tream file(fname);if ( !file )cout出現(xiàn)未知錯(cuò)誤導(dǎo)致無法打開!teanonameagesextitlecourse0course1course2score;p=new CNode;p-data.SetNameAndSex(name,sex);p-data.SetAge(age);p-data.SetData(title,teano);p-data.SetCourse(course0,course1,course2);p-data.SetScore(score);tail-next=p;tail=p;num+;tail-next=NULL;void Print()
12、for ( p=head-next; p!=NULL; p=p-next)p-data.ShowInfo();coutendl;void Append()while ( 1 )p=new CNode;cout請輸入:endl;coutname;coutage;coutsex;p-data.SetNameAndSex(name,sex);p-data.SetAge(age);couttitle;coutteano;p-data.SetData(title,teano);coutcourse0course1course2;p-data.SetCourse(course0,course1,cours
13、e2);coutscore;p-data.SetScore(score);p-next=tail-next;tail-next=p;tail=p;num+;char c;coutc;cin.get();if ( c!=y )break;tail-next=NULL;Print();int SortMenu()cout1.按職工號排序endl;cout2.按教學(xué)效果綜合評分排序endl;cout0.退出endl;coutchoice;return choice;void SortMenuControl()while ( 1 )int choice=SortMenu();if ( choice=0
14、 )break;switch ( choice )case 1:SortByTeano();break;case 2:SortByScore();break;Print();void InsertByTeano(CNode *newp)for ( pre=head,p=head-next; p!=NULL; pre=p,p=p-next)if ( newp-data.GetTeano() data.GetTeano() )break;newp-next=p;pre-next=newp;void SortByTeano()p=head-next;head-next=NULL;CNode *nex
15、tp;while ( p!=NULL )nextp=p-next;InsertByTeano(p);p=nextp;void InsertByScore(CNode *newp)for ( pre=head,p=head-next; p!=NULL; pre=p,p=p-next)if ( newp-data.GetScore() data.GetScore() )break;newp-next=p;pre-next=newp;void SortByScore()p=head-next;head-next=NULL;CNode *nextp;while ( p!=NULL )nextp=p-n
16、ext;InsertByScore(p);p=nextp;int SearchMenu()cout1.按姓名查找endl;cout2.按課程查找endl;cout0.退出endl;coutchoice;return choice;void SearchMenuControl()while ( 1 )int choice=SearchMenu();if ( choice=0 )break;switch ( choice )case 1:SearchByName();break;case 2:SearchByCourse();break;void SearchByName()int n=0;cou
17、tname;for ( p=head-next; p!=NULL; p=p-next)if ( p-data.GetName()=name)p-data.ShowInfo();n+;if ( n=0 )cout沒有相關(guān)記錄endl;coutendl;void SearchByCourse()int n=0;coutc;for ( p=head-next; p!=NULL; p=p-next)vector course=p-data.GetCourse();for (int i=0; idata.ShowInfo();n+;break;if ( n=0 )cout沒有相關(guān)記錄endl;coutn
18、ext=NULL;while ( 1 )p=new CNode;cout請輸入:endl;coutname;coutage;coutsex;p-data.SetNameAndSex(name,sex);p-data.SetAge(age);couttitle;coutteano;p-data.SetData(title,teano);coutcourse0course1course2;p-data.SetCourse(course0,course1,course2);coutscore;p-data.SetScore(score);tail-next=p;tail=p;num+;coutc;cin.get();if ( c!=y )break;tail-next=NULL;void Save()char fname80;coutfname;ofstream file(fname);if ( !file )cout出現(xiàn)未知錯(cuò)誤導(dǎo)致無法打開!next; p!=NULL; p=p-next)vector course=p-data.GetCourse();file
溫馨提示
- 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)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 別墅建筑工程合同范本
- 加盟入股協(xié)議合同范本
- 租賃攤位合同范本
- 出售大米合同范本
- 醫(yī)美合作合同范本
- 農(nóng)村房租建設(shè)合同范例
- 兼職簽定勞動合同范本
- 出售附近廠房合同范本
- 農(nóng)戶房屋流轉(zhuǎn)合同范本
- 個(gè)人欠款合同范本模板
- DG-TJ 08-2048-2024 民用建筑電氣防火設(shè)計(jì)標(biāo)準(zhǔn)
- 2025年中智集團(tuán)招聘筆試參考題庫含答案解析
- 肝癌圍手術(shù)期的護(hù)理
- 黑龍江省哈爾濱市南崗區(qū)2024-2025學(xué)年九年級上學(xué)期期末考試英語試題(含答案)
- 殘疾人就業(yè)培訓(xùn)
- Photoshop+2024學(xué)習(xí)手冊:第1課認(rèn)識與操作基礎(chǔ)
- 《不同血流限制訓(xùn)練方案對膝關(guān)節(jié)損傷運(yùn)動員下肢功能的影響》
- 藥品經(jīng)營企業(yè)(批發(fā)和零售)面臨的風(fēng)險(xiǎn)點(diǎn)和應(yīng)對措施
- 基本公共衛(wèi)生服務(wù)項(xiàng)目培訓(xùn)
- 北師大版(2024新版)七年級上冊數(shù)學(xué)期末模擬測試卷(含答案)
- 無人機(jī)組裝與調(diào)試 課件 項(xiàng)目1任務(wù)1 多旋翼無人機(jī)飛行平臺組裝調(diào)試
評論
0/150
提交評論