C++機(jī)房計(jì)費(fèi)管理系統(tǒng)_第1頁(yè)
C++機(jī)房計(jì)費(fèi)管理系統(tǒng)_第2頁(yè)
C++機(jī)房計(jì)費(fèi)管理系統(tǒng)_第3頁(yè)
C++機(jī)房計(jì)費(fèi)管理系統(tǒng)_第4頁(yè)
C++機(jī)房計(jì)費(fèi)管理系統(tǒng)_第5頁(yè)
已閱讀5頁(yè),還剩33頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、實(shí)用目錄一、需求分析 2二、概要設(shè)計(jì)2三、詳細(xì)設(shè)計(jì)4四、調(diào)試分析17五、用戶手冊(cè)17六、測(cè)試數(shù)據(jù)18七、 附錄20文案一、需求分析1. 輸入功能:輸入30名學(xué)生的學(xué)號(hào)、班級(jí)、姓名、上機(jī)起始時(shí)間。2. 計(jì)算功能:計(jì)算每個(gè)下機(jī)學(xué)生的上機(jī)費(fèi)用,每小時(shí)1元。(上機(jī)費(fèi)用=上機(jī)時(shí)間1.0/h,不足一小時(shí)按一小時(shí)計(jì)算)3. 查詢功能:按條件(班級(jí)、學(xué)號(hào)、姓名)顯示學(xué)生的上機(jī)時(shí)間。4. 機(jī)器使用情況的顯示(顯示方式不限但要一目了然)5. 要求:1)源文件采用多文件的工程結(jié)構(gòu);2)數(shù)據(jù)存儲(chǔ)采用文件形式;3)米用面向?qū)ο蠓椒ㄔO(shè)計(jì);4)功能完善,適當(dāng)?shù)淖⑨專?)關(guān)于文件的內(nèi)容需要自學(xué);、概要設(shè)計(jì)int getcla

2、();獲取班級(jí)號(hào) int gettag(); 獲取標(biāo)記 int getst unum();獲取學(xué)號(hào) int getco mnum();獲取上機(jī)號(hào) double cou ntht();計(jì)算上機(jī)時(shí)間 int cou ntm();計(jì)算上機(jī)費(fèi)用 void disp();顯示void disp2();顯示 21. 學(xué)生類的定義:Student學(xué)生類) int tag; 刪除標(biāo)記 char n ame20;學(xué)生姓名 in t cla;班級(jí) int stunum;學(xué)號(hào) int comnum;上機(jī)號(hào) time_t stime;開(kāi)始上機(jī)時(shí)間 time_t otime;下機(jī)時(shí)間 double htime;上機(jī)總時(shí)

3、間 int mon ey; 上機(jī)費(fèi)用 Stude nt();構(gòu)造函數(shù)Void upcom(char Name20,int Cla,int Stunum,int Comnum);上 機(jī)操作int downcom();下機(jī)操作 void delstu();刪除操作 void setotime();設(shè)置下機(jī)時(shí)間 time_t gettime();獲取當(dāng)前時(shí)間 char* get name();獲取姓名2. 學(xué)生庫(kù)類定義:StuData學(xué)生庫(kù)類)int top;學(xué)生記錄指針Student studentMAXS;學(xué)生記錄 StuData();構(gòu)造函數(shù)Stude nt* search nu m(i nt

4、 Stunum) 按學(xué)號(hào)搜索學(xué)生Student* searchcla(int Cla);按班 級(jí)搜索學(xué)生void dispbycla(int Cla);按班級(jí)顯 示學(xué)生Stude nt*search name(char *Name); 按姓名顯示學(xué)生void dispall();顯示所有學(xué)生信息 void upcom(char Name20,i nt Cla,i nt Stunu m,i nt Comnu m);上機(jī) 操作void downcom(int Stunum);下機(jī) 操作int search();搜索操作StuData();析構(gòu)函數(shù)3. 電腦類的定義:Computer(電腦類)int

5、 tag;刪除標(biāo)記int comnum;電腦號(hào) Computer();構(gòu)造函數(shù) void setco mnu m(i nt Comnu m); 設(shè)置電腦號(hào)int getco mnum(); 獲取電腦號(hào) void upcom(); 上機(jī)操作 void downcom();下機(jī)操作 int gettag();獲取標(biāo)記Computer computer30; 腦記錄電ComData();構(gòu)造函數(shù)Computer* searchcom();搜索空閑電腦Computer* search nu m(i ntCom num)按電腦號(hào)搜索4.電腦庫(kù)類的定義:ComData( 電腦庫(kù)類)int upcom();

6、 上機(jī)操作 void disp(); 顯示 ComData();析構(gòu)函數(shù)三、詳細(xì)設(shè)計(jì)1. 學(xué)生類成員函數(shù)的定義:Stude nt:Stude nt() /構(gòu)造函數(shù)void Stude nt:upcom(char Name20,i nt Cla,i nt Stunu m,i nt Comnum) /上機(jī)strcpy( name,Name);tag=1;cla=Cla;stunum=St unum;comnum=Co mnum;stime=gettime();int Stude nt:dow ncom() / 下機(jī)otime=gettime(); setotime(); delstu();disp

7、();return comnum;void Stude nt:delstu() /更改上機(jī)標(biāo)記tag=0;void Stude nt:setotime() / 獲取下機(jī)時(shí)間otime=gettime();time_t Stude nt:gettime() /獲取當(dāng)前時(shí)間return time(NULL);char* Stude nt:get name() /獲取姓名return n ame;int Stude nt:getcla() /獲取班級(jí)return cla;int Stude nt:gettag() /獲取上機(jī)標(biāo)記return tag;int Stude nt:getst unum()

8、 /return stu num;int Stude nt:getco mnum() /return comnum;double Stude nt:cou ntht() /獲取學(xué)號(hào)獲取上機(jī)號(hào)計(jì)算總上機(jī)時(shí)間return difftime(otime,stime);int Stude nt:cou ntm() /計(jì)算上機(jī)費(fèi)用if(i nt)cou ntht()%3600=0)return (i nt)cou ntht()/3600;return (i nt)cou ntht()/3600)+1;void Stude nt:disp() / 顯示coutvv姓名:namevv vv班級(jí):cla 學(xué)號(hào)

9、:stunum 上機(jī)號(hào)comnumendl;coutvv開(kāi)始上機(jī)時(shí)間:asctime(localtime(&stime) 上機(jī)總時(shí) 間:countht()/3600.00 小時(shí) 上機(jī)費(fèi)用:countm()元endl;void Stude nt:disp2() / 顯示coute ndle ndl上機(jī)成功e ndl;coutvv姓名:nameendl班級(jí):vvclavvendl學(xué)號(hào):stunumvvendlvv開(kāi)始上機(jī)時(shí)間:vvasctime(localtime(&stime)vv上機(jī)號(hào):vvco mnum vve ndl;/coutvv開(kāi)始上機(jī)時(shí)間:vvstimevv vv 上機(jī)總時(shí)間:vvc

10、ountht()vv vv上機(jī)費(fèi)用:vvcountm()vvendl;2. 學(xué)生庫(kù)類成員函數(shù)定義:StuData:StuData() /構(gòu)造函數(shù),將 student.txt中的內(nèi)容讀到 student中Stude nt s;top=-1;ifstream fin (stude nt.txt);while(1)fin .read(char *)&s,sizeof(s);if(!fi n)break;top+;stude nttop=s;fin .close();Stude nt* StuData:search num(i nt Stu num) / 按學(xué)號(hào)搜索for(i nt i=0;i=top

11、;i+)if(stude nti.getst unum( )=St unum&stude nti.gettag()=1)return &stude nti;return NULL;Stude nt* StuData:searchcla(i nt Cla) /按班級(jí)搜索for(i nt i=0;i=top;i+)if(stude nti.getcla()=Cla&stude nti.gettag()=1)return &stude nti;return NULL;void StuData:dispbycla(i nt Cla) /按班級(jí)顯示for(i nt j=0;jv=top;j+)if(st

12、ude ntj.getcla()=Cla&stude ntj.gettag()=1)stude ntj.disp();coute ndl;Stude nt* StuData:search name(char *Name) / 按姓名搜索for(i nt i=0;i=top;i+)if(!strcmp(stude nti.get name(),Name)&stude nti.gettag()=1)return &stude nti;return NULL;void StuData:dispall() /顯示所有學(xué)生for(i nt i=0;idow ncom();int StuData:sear

13、ch() /機(jī)房學(xué)生查詢char choice;char n ame20;int stunum;int cla;Stude nt *s;while(choice!=0)e ndle ndl;coutvvendlendlvv 機(jī)房學(xué)生查詢cout1按姓名查詢e ndl;cout2按學(xué)號(hào)查詢e ndl;cout3按班級(jí)查詢e ndl;cout4全部學(xué)生信息 choice;switch(choice)case 1:system(cls);coutvv請(qǐng)輸入學(xué)生姓名:cinn ame;s=search name( name);if(s=NULL)coutvv機(jī)房沒(méi)有此人break;s-disp();b

14、reak;case 2:system(cls);coutvv請(qǐng)輸入學(xué)生學(xué)號(hào): cin st unum;s=search nu m(st unu m); if(s=NULL)vve ndl;vve ndl;vve ndl;vve ndl;coutvv機(jī)房沒(méi)有此人vvendl;break;s-disp();break;case 3:system(cls);cout請(qǐng)輸入班級(jí)號(hào): cla;s=searchcla(cla);if(s=NULL)cout機(jī)房沒(méi)有該班級(jí)的人!endl;break;dispbycla(cla);break;case 4:system(cls);coute ndle ndl

15、機(jī)房所有上機(jī)學(xué)生信息如下e ndle ndl;dispall();break;case O:return 0;default:cout輸入有誤,請(qǐng)重新輸入:endl;cout按任意鍵返回endl;getch();system(cls);StuData:StuData() / 析構(gòu)函數(shù),將 student中數(shù)據(jù)寫(xiě)到 srudent.txt 中ofstream fout(stude nt.txt);for(i nt i=0;i=top;i+)if(stude nti.gettag()=1)fout.write(char* )&stude nti,sizeof(stude nti);fout.clo

16、se();3. 電腦類成員函數(shù)定義:Computer:Computer() /構(gòu)造函數(shù)tag=0;void Computer:setco mnu m(i nt Comnum) /設(shè)置電腦號(hào)comnum=Co mnum;int Computer:getco mnum() / 獲取電腦號(hào)return comnum;void Computer:upcom() / 上機(jī)tag=1;void Computer:dow ncom() / 下機(jī)tag=0;int Computer:gettag() / 獲取上機(jī)標(biāo)記return tag;4. 電腦庫(kù)類成員函數(shù)定義:ComData:ComData() /構(gòu)造函

17、數(shù)Computer c;ifstream fin (computer.txt);for(i nt j=O;jMAXC;j+)fin .read(char* )& c,sizeof(c);computerj=c;fin .close();for(int i=0;iMAXC;i+)computeri.setco mnu m(i+1);Computer* ComData:searchcom() / 搜索空閑電腦for(int i=0;iMAXC;i+)if(computeri.gettag()=0)return &computeri;return NULL;Computer* ComData:sea

18、rch num(i nt Comn um) / 按電腦號(hào)搜索電腦for(int i=0;iMAXC;i+)if(computeri.getco mnum( )=Co mnum)return &computeri;return NULL;int ComData:upcom() /上機(jī)Computer *p=searchcom();if(p=NULL)cout機(jī)房已滿,不能上機(jī)upcom();return p-getco mnum();void ComData:disp() / 顯示coutvvendlvvendlvv電腦使用情況如下,1為被使用中,O為空閑中! e ndle ndl;for(in

19、t i=0;iMAXC;i+)coutcomputeri.getco mnum();prin tf(%4d,computeri.gettag();if(i+1)%6=0)coute ndl;ComData:ComData() / 析構(gòu)函數(shù)ofstream fout(computer.txt);for(int i=0;iMAXC;i+)if(computeri.gettag()=1)fout.write(char* )&computeri,sizeof(computeri);fout.close();四、調(diào)試分析1. 調(diào)試前,界面有些凌亂,選擇某項(xiàng)功能后,之前的菜單仍然在界面上;調(diào)試時(shí), 適當(dāng)加

20、入了清屏函數(shù),使界面更加簡(jiǎn)潔清晰。2. 調(diào)試前,當(dāng)輸入的內(nèi)容不合法時(shí)沒(méi)有任何提示,導(dǎo)致某些功能出現(xiàn)故障;調(diào)試 時(shí)對(duì)輸入內(nèi)容的合法性做出的判斷,并給出了相映的提示信息。3. 體會(huì):C+語(yǔ)言課程設(shè)計(jì)和現(xiàn)代計(jì)算機(jī)技術(shù)的實(shí)際應(yīng)用相結(jié)合,是我們?cè)诒倦A段 學(xué)完理論課程之后對(duì)自己該方面的能力的一次很好的檢驗(yàn)。從開(kāi)始的算法思路到運(yùn)行調(diào)試后的美觀的圖形界面以及另人興奮的可用程序,都是一個(gè)很好的學(xué) 習(xí)和鍛煉的過(guò)程。使我們鞏固了原有的理論知識(shí),培養(yǎng)了我們靈活運(yùn)用和組合 集成所學(xué)過(guò)知識(shí)及技能來(lái)分析、解決實(shí)際問(wèn)題的能力。使我們體會(huì)到自身知識(shí) 和能力能在實(shí)際中的應(yīng)用和發(fā)揮。這不但激發(fā)了我的創(chuàng)新意識(shí),還開(kāi)發(fā)了我的 創(chuàng)造能力

21、、培養(yǎng)了我的溝通能力。老師對(duì)我們進(jìn)行了細(xì)心、耐心的指導(dǎo),鼓勵(lì) 我們對(duì)程序進(jìn)行合理改進(jìn),培養(yǎng)了我們的創(chuàng)新意識(shí)和創(chuàng)新能力。原來(lái)是我認(rèn)為 可怕的課程設(shè)計(jì),就在種種輔助條件下完成了,心里有說(shuō)不出的高興。這是一 個(gè)發(fā)現(xiàn)問(wèn)題和解決問(wèn)題的過(guò)程,從困惑到明朗,從苦惱道興奮。我一步步地走 過(guò)來(lái),發(fā)現(xiàn)編程真是一個(gè)奇妙刺激的旅程。特別是當(dāng)我把一個(gè)自己認(rèn)為毫無(wú)可 能的事情完成自后,那種感覺(jué)簡(jiǎn)直不能用言語(yǔ)來(lái)表達(dá)。感謝這次課程設(shè)計(jì)給我 帶來(lái)的全新體驗(yàn)和豐富經(jīng)驗(yàn)。我會(huì)把它換成我以后奮斗的源泉。五、用戶手冊(cè)1. 本程序的運(yùn)行環(huán)境為DOS操作系統(tǒng),執(zhí)行文件為:機(jī)房管理系統(tǒng).exe;2. 進(jìn)入演示程序后,即顯示對(duì)話形式的提示操作

22、過(guò)程,3. 選擇上機(jī)項(xiàng)后,輸入上機(jī)學(xué)生的基本信息;4選擇下級(jí)項(xiàng)后,輸入要下機(jī)學(xué)生的學(xué)號(hào)即可,系統(tǒng)自動(dòng)給出上機(jī)總時(shí)間和費(fèi)用;5. 選擇學(xué)生信息查詢項(xiàng)后,可按各種信息搜索,選擇相應(yīng)選項(xiàng)即可;6. 選擇電腦使用情況項(xiàng)后,系統(tǒng)便會(huì)顯示所有電腦的被使用情況。六、測(cè)試數(shù)據(jù)主界面:上機(jī)操作:上機(jī)成功姓笛:huhu.班縱102023學(xué)導(dǎo): 1020235S弁始上機(jī)B寸間:Sat Feb 25 09:57:45 2CU2 上機(jī)號(hào):1按任意鍵返回主菜單下機(jī)操作:猜輸入需要結(jié)賬下機(jī)的人的學(xué)號(hào):10202313姓各黃痔班級(jí):102023 學(xué)號(hào):10202313 上機(jī)號(hào)&開(kāi)始上機(jī)時(shí)間:Non Feb 20 06:06:

23、19 2012上機(jī)總時(shí)可;121.836小時(shí) 上機(jī)費(fèi)用:22元k任意鍵返回主菜單實(shí)用查詢界面:機(jī)房學(xué)生查詢12 3 4 0息 詢?cè)冊(cè)? 查查查生#平 名號(hào)峯王 姓學(xué)鳶回返按姓名查詢:肓輸學(xué)半姓名aoxiaolian上名:caoxiaolian 班級(jí)*_機(jī)總時(shí)間 60.2619小時(shí) 安任意鍵追回:Fri Feb 17132B23 學(xué)號(hào)* 2220:24:21 2012上機(jī)費(fèi)用缸元上機(jī)號(hào)4按學(xué)號(hào)查詢:102023 學(xué)號(hào);10202313 上機(jī)號(hào) 8Feb 20 08:08:19 2012詡弘小日寸上機(jī)費(fèi)用;2元按班級(jí)查詢:請(qǐng)輸入班級(jí)號(hào)=102023勝名:daixiAohui班級(jí):佃2陰3學(xué)號(hào);11

24、上機(jī)號(hào)3 肝始上機(jī)時(shí)間:上機(jī)總時(shí)間:635?3i小時(shí)上機(jī)費(fèi)用:64元Fri Feb 17 17:05:41 2012L姓咅匕caoxiaoliang 班級(jí):102023 學(xué)號(hào)* 22 上機(jī)號(hào)4乩 臟名I liyue|開(kāi)站上和寸間: 上機(jī)忌時(shí)可:潔上機(jī)時(shí)間:Fri Feb 17 20:24:21 2012 F機(jī)想時(shí)間:60如9小時(shí)上機(jī)費(fèi)用元班級(jí);102023學(xué)號(hào);10上機(jī)號(hào)2 Fri Feb 丄? 21:21:58 2012 59-3017寸上機(jī)費(fèi)陽(yáng):盹元姓名:huhuan班級(jí):102023學(xué)號(hào):5上機(jī)號(hào)6Fri Feb 17 21=24:40 2012已25冊(cè)小日寸 上機(jī)費(fèi)用;60元牲容:xi

25、aopel開(kāi)艶勰班級(jí):102023學(xué)號(hào):3上機(jī)號(hào)7Fri Feb 17 21:2S:08 2012別泡咖小時(shí)上機(jī)費(fèi)用盹元Km山詢小時(shí)上機(jī)費(fèi)Mon Feb 20 0S:0S:19 2012:1元電腦唄使用情況:電腦使用情況如下,為被使用中,為空閑中!ts安任意鍵返回主菜單七、附錄/ Student.h”#ifndef Stude nt_H_H#define Stude nt_H_H typedef long time_t; class Stude nt public:Stude nt();構(gòu)造函數(shù)/上機(jī)void upcom(char Name20,i nt Cla,i nt Stunu m,i

26、nt Comnu m); int dow ncom();下機(jī)void delstu();/更改上機(jī)標(biāo)記void setotime();/獲取下機(jī)時(shí)間time_t gettime();/獲取當(dāng)前時(shí)間char* get name();/ 獲取姓名in t getcla();/ 獲取班級(jí)in t gettag();/獲取上機(jī)標(biāo)記in t getstu nu m();獲取學(xué)號(hào)in t getcom num();獲取上機(jī)號(hào)double cou ntht();/計(jì)算總上機(jī)時(shí)間int coun tm();/計(jì)算上機(jī)費(fèi)用void disp(); / 顯示 void disp2();顯示private:int

27、tag;char n ame20;int cla;int stunum;int comnum; time_t stime; time_t otime; double htime; int in thtime; int mon ey;#en dif/ StuData.h”#ifndef StuData_H_H #defi ne StuData_H_H#i ncludeStude nt.hconst int MAXS=30;class StuData public:StuData();/構(gòu)造函數(shù)Stude nt* search num(i nt Stu num);/ 按學(xué)號(hào)搜索Stude nt*

28、searchcla(i nt Cla);按班級(jí)搜索void dispbycla(i nt Cla);按班級(jí)顯示Stude nt* search name(char *Name);按姓名搜索/上機(jī)void dispall();顯示所有學(xué)生void upcom(char Name20,i nt Cla,i nt Stunu m,i nt Comnu m);void dow ncom(i nt Stunu m);/ 下機(jī)int search();/機(jī)房學(xué)生查詢StuData(); / 析構(gòu)函數(shù)private:int top;Stude nt stude ntMAXS;#en dif/ Compute

29、r.h ”#ifndef Computer_H_H#defi ne Computer_H_Hclass Computerpublic:Computer();/ 構(gòu)造函數(shù)void setco mnu m(i nt Comnu m);設(shè)置電腦號(hào)in t getcom num();獲取電腦號(hào)void upcom();/ 上機(jī)void dow ncom();下機(jī)in t gettag();/獲取上機(jī)標(biāo)記private:int tag;int comnum;#en dif/ ComData.h ”#ifndef ComData_H_H#defi ne ComData_H_H#i ncludeComput

30、er.hconst int MAXC=30;class ComDatapublic:ComData();/構(gòu)造函數(shù)Computer* searchcom(); / 搜索空閑電腦Computer* searchnum(int Comnum); / 按電腦號(hào)搜索電腦 int upcom();上機(jī)void disp();/ 顯示ComData();/ 析構(gòu)函數(shù)private:Computer computer30;;#en dif/ Student.cpp#in clude Stude nt.h#in clude #in clude #in clude #i nclude Stude nt:Stud

31、e nt()/ 構(gòu)造函數(shù)/上機(jī)void Stude nt:upcom(char Name20,i nt Cla,i nt Stunu m,i nt Comnum) strcpy (n ame,Name);tag=1;cla=Cla;stunum=St unum;comnum=Co mnum; stime=gettime();int Stude nt:dow ncom()/ 下機(jī)otime=gettime(); setotime();delstu();disp();return comnum;void Stude nt:delstu()/更改上機(jī)標(biāo)記tag=0;void Stude nt:set

32、otime()/獲取下機(jī)時(shí)間otime=gettime();time_t Stude nt:gettime()/ 獲取當(dāng)前時(shí)間return time(NULL);char* Stude nt:get name() / 獲取姓名return n ame;int Stude nt:getcla()獲取班級(jí)return cla;int Stude nt:gettag()獲取上機(jī)標(biāo)記return tag;文案int Stude nt:getst unum()return stu num;int Stude nt:getco mnum() return comnum;double Stude nt:co

33、 un tht()/獲取學(xué)號(hào)/獲取上機(jī)號(hào)/計(jì)算總上機(jī)時(shí)間return difftime(otime,stime);int Stude nt:cou ntm()/ 計(jì)算上機(jī)費(fèi)用if(i nt)cou ntht()%3600=0)return (i nt)co un tht()/3600; return (i nt)co un tht()/3600)+1;void Stude nt:disp()/ 顯示cout姓名:name 班級(jí):cla學(xué)號(hào):stunum上機(jī)號(hào)co mnum e ndl;cout開(kāi)始上機(jī)時(shí) 間:asctime(localtime(&stime)上機(jī)總 時(shí) 間:countht()/

34、3600.00小時(shí)上機(jī)費(fèi)用:countm()元endl;void Stude nt:disp2() / 顯示coute ndle ndl 上機(jī)成功e ndl;cout姓名:nameendl班級(jí):claendl學(xué)號(hào):stunumendl開(kāi)始上 機(jī)時(shí)間:asctime(localtime(&stime)上機(jī)號(hào):co mnum e ndl;/cout開(kāi)始上機(jī)時(shí)間:stime上機(jī)總時(shí)間:countht()上機(jī)費(fèi)用:co un tm()e ndl;/ StuData.cpp ”#in clude#i ncludeStuData.h#i ncludeStude nt.h#in clude#in clude

35、#i nclude#in cludeStuData:StuData()/ 構(gòu)造函數(shù)Stude nt s;top=-1;ifstream fin (stude nt.txt);while(1)fin. read(char *)& s,sizeof(s);if(!fi n)break;top+;stude nttop=s;fin. close();Stude nt* StuData:search num(i nt Stu num)/ 按學(xué)號(hào)搜索for(i nt i=O;i=top;i+)if(stude nti.getst unum( )=St unum&stude nti.gettag()=1)

36、return & stude nti;return NULL;Stude nt* StuData:searchcla(i nt Cla)/ 按班級(jí)搜索for(i nt i=0;i=top;i+)if(stude nti.getcla()=Cla&stude nti.gettag()=1)return & stude nti;return NULL;void StuData:dispbycla(i nt Cla)按班級(jí)顯示for(i nt j=0;j=top;j+)if(stude ntj.getcla()=Cla&stude ntj.gettag()=1)stude ntj.disp();co

37、ute ndl;Stude nt* StuData:search name(char *Name)/ 按姓名搜索for(i nt i=0;i=top;i+)if(!strcmp(stude nti.get name(),Name )&stude nti.gettag()=1) return & stude nti;return NULL;void StuData:dispall()顯示所有學(xué)生for(i nt i=0;i=top;i+)if(stude nti.gettag()=1)stude nti.setotime();stude nti.disp();coutdow ncom();int

38、 StuData:search()/ 機(jī)房學(xué)生查詢char choice;char n ame20;int stunum;int cla;Stude nt *s;while(choice!=0)coutendlendl機(jī)房學(xué)生查詢endlendl;cout-1按姓名查詢-e ndl;cout-2按學(xué)號(hào)查詢-e ndl;cout-3按班級(jí)查詢-e ndl;cout-4全部學(xué)生信息-e ndl;cout-0返回主采單- choice; switch(choice) case 1:system(cls);cout請(qǐng)輸入學(xué)生姓名:e ndl; cinn ame;s=search name( name)

39、;if(s=NULL)cout機(jī)房沒(méi)有此人disp();break;case 2:system(cls);cout請(qǐng)輸入學(xué)生學(xué)號(hào): st unum;s=search nu m(st unu m);if(s=NULL)cout機(jī)房沒(méi)有此人disp();break;case 3:system(cls);cout請(qǐng)輸入班級(jí)號(hào): cla;s=searchcla(cla);if(s=NULL)cout機(jī)房沒(méi)有該班級(jí)的人!e ndl;break;dispbycla(cla);break;case 4:system(cls);en dle ndl;coute ndle ndl 機(jī)房所有上機(jī)學(xué)生信息如下dis

40、pall();break;case O:return 0;default:cout輸入有誤,請(qǐng)重新輸入:e ndl;cout按任意鍵返回endl;getch();system(cls);StuData:StuData()/ 析構(gòu)函數(shù)ofstream fout(stude nt.txt);for(i nt i=0;i=top;i+)if(stude nti.gettag()=1)fout.write(char* )&;stude nti,sizeof(stude nti); fout.close();/ Computer.cpp ”#i ncludeComputer.hComputer:Comp

41、uter()/ 構(gòu)造函數(shù)tag=0;void Computer:setco mnu m(i nt Comnum)/ 設(shè)置電腦號(hào)comnum=Co mnum;int Computer:getco mnum() 獲取電腦號(hào)return comnum;void Computer:upcom()/ 上機(jī)tag=1;void Computer:dow ncom()/ 下機(jī)tag=0;int Computer:gettag()/ 獲取上機(jī)標(biāo)記return tag;/ ComData.cpp ”#i ncludeComData.h#i ncludeComputer.h#in clude#in clude#i

42、n cludeComData:ComData()/ 構(gòu)造函數(shù)Computer c;/*for(int i=0;iMAXC;i+)computeri.setco mnu m(i+1);*/ifstream fin (computer.txt);for(i nt j=O;jMAXC;j+)fin. read(char* )&c,sizeof(c); computerj=c;fin. close();for(i nt i=0;iMAXC;i+)computeri.setco mnu m(i+1);Computer* ComData:searchcom() / 搜索空閑電腦for(i nt i=0;iMAXC;i+)if(computeri.gettag()=0)return & computeri;return NULL;Computer* ComData:searchnum(int Comnum) / 按電腦號(hào)搜索電腦 for(i nt i=0;iMAXC;i+)if(computeri.getco mnum( )=Co mnum)return & computeri;return NULL;int ComData:upcom()上機(jī)Computer *p=searchc

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論