手機(jī)資費管理系統(tǒng)C++_第1頁
手機(jī)資費管理系統(tǒng)C++_第2頁
手機(jī)資費管理系統(tǒng)C++_第3頁
手機(jī)資費管理系統(tǒng)C++_第4頁
手機(jī)資費管理系統(tǒng)C++_第5頁
已閱讀5頁,還剩21頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、程序設(shè)計綜合實習(xí)總結(jié)報告 設(shè)計題目:手機(jī)資費管理系統(tǒng) 實驗地點:山東農(nóng)業(yè)大學(xué)本部文理大樓實驗室 完成起止日期: 2015.8.31-2015.9.6目錄一、設(shè)計思路 3二、具體實現(xiàn) 4 1、數(shù)據(jù)類 4 2、操作類 6 3、具體代碼 7 三、測試數(shù)據(jù)設(shè)計 18四、運行調(diào)試 19 1、用戶 19 2、管理員 23 五、設(shè)計體會與小結(jié) 25 三、 設(shè)計思路手機(jī)資費管理系統(tǒng)分為管理員和用戶兩個登陸板塊,管理員負(fù)責(zé)資費標(biāo)準(zhǔn)、資費套餐及用戶信息的管理;用戶模塊包括套餐的選擇、繳費、業(yè)務(wù)模擬(打電話、發(fā)短信、上網(wǎng))、余額查詢、費用詳單查詢等。系統(tǒng)類設(shè)計分為數(shù)據(jù)類和操作類,數(shù)據(jù)類有管理員類,用戶類,資費類,套

2、餐類;操作類對數(shù)據(jù)類中的數(shù)據(jù)進(jìn)行操作。該系統(tǒng)的用戶信息,套餐信息等都是通過外部文件導(dǎo)入到程序中,并輸出外部文件中,同時管理員也可實時增加用戶,套餐等,并輸出到文件中。用戶界面:查看個人信息;選擇套餐;修改密碼;打電話;發(fā)短信;在線繳費;查詢套餐使用情況;上網(wǎng)。管理員:添加用戶;刪除用戶;添加套餐;修改套餐;查找用戶。四、 具體實現(xiàn)1、數(shù)據(jù)類(1) 、用戶數(shù)據(jù)類 class user private: string name; string telephone; string sfz;/身份證號 string password; public: string getname() return n

3、ame; string getphone() return telephone; string getpassword() return password; user() ; user() ; friend ostream& operator<<(ostream &out ,const user &use); friend istream& operator>>(istream &in, user &use); ;(2) 、管理員數(shù)據(jù)類class regulatorpublic: string password,id; r

4、egulator() regulator();(3) 、資費數(shù)據(jù)類class fare private: string uphone; double money; /余額 double time; /剩余通話時長 double gprs_sy;/流量余額 double duanxin;/短信條數(shù) double money_minute;/每分鐘多少錢 double money_tiao; /每條多少錢 public : string getuphone() return uphone; double getmoney() return money; double gettime() retur

5、n time; double getgprs_sy() return gprs_sy; double getduanxin() return duanxin; double getmoney_minute() return money_minute; double getmoney_tiao() return money_tiao; double getmoney_web() return money_web; void setmoney(double a) money=a; void settime(double b) time=b; void setgprs_sy(double c) gp

6、rs_sy=c; void setduanxin(double d) duanxin=d; void setmoney_minute(double e) money_minute=e; void setmoney_tiao(double f) money_tiao=f; void couts() cout<<"余額為"<<money<<"剩余通話時長為"<<time<<"剩余流量為"<<gprs_sy<<"剩余短信條數(shù)為"<&

7、lt;duanxin<<"超出套餐后,每分鐘通話時間價格為"<<money_minute<<"超純套餐后,每條短信的價格為"<<money_tiao<<endl; friend ostream& operator<<(ostream&out,const fare &fa); friend istream& operator>>(istream&in,fare&fa); ;(4) 、套餐數(shù)據(jù)類class taocan priv

8、ate: string taocan_id;/套餐代號 double yuezu; /月租 double gprs;/ 流量 double allduanxin; /每月多少條短信 double alltime; /每月可免費通話時長 public: void setyuezu(double a) yuezu=a; void setgprs(double b) gprs=b; void setallduanxin(double c) allduanxin=c ; void setalltime(double d) alltime=d; string gettaocanid() return t

9、aocan_id; double getyuezu() return yuezu; double getgprs() return gprs; double getallduanxin() return allduanxin; double getalltime() return alltime; void inform() cout<<"套餐代號為"<<taocan_id<<"該套餐每月月租為"<<yuezu<<"每月基礎(chǔ)流量為"<<gprs<<&q

10、uot;每月免費短信條數(shù)為"<<allduanxin<<"每月可免費通話時長為"<<alltime<<endl; friend ostream& operator<<(ostream&out,const taocan &ta); friend istream& operator>>(istream&in,taocan&ta); ;2、操作類(1) 用戶操作類lass cuser private : vector<user>myinor

11、m; vector<user>:iterator myi; vector<fare>myfare; vector<fare>:iterator myf; vector<taocan>vtaocan; taocan mytaocan; vector<taocan>:iterator tao; vector<taocan>taocan_; user me; fare mefare; taocan tancan_sao; public: cuser(string s_phone); cuser() cuser() void me

12、nu(); int run_menu(); void login(); void call(); /打電話 void message();/發(fā)短信 void select_taocan(); /選擇套餐 void pay() ;/在線繳費 void web(); /上網(wǎng);(2) 、管理員操作類class cregulator private : map<string,string>all; /管理員和用戶的登錄賬號和密碼全在這 vector<user>users; map<string,string>:iterator m; vector<user&g

13、t;:iterator u; vector<fare>allfare; vector<fare>:iterator af; vector<taocan>taocans; vector<taocan>:iterator tc_it; user cus; taocan tc; public: void menu(); void role_login(); void login( int role,string id,string password); void regulator_menu(); void regulator_login(); voi

14、d add_user(); void del_user(); void add_taocan(); void xiugai(); void find(); void xiugai_taocan(); void chan_pwd(string id1); void web(); cregulator(); cregulator();3、具體代碼(1)、登陸界面void cregulator:menu() printf(" 歡迎登錄手機(jī)資費管理系統(tǒng) n"); printf(" 1.管理員登錄 n") ; / ! printf(" 2.用戶登錄 n&

15、quot;); void cregulator:role_login() int r;string allid,allpassword; while(1) menu(); cin>>r; if(r!=0) cout<<"請輸入用戶名和密碼"<<endl; cin>>allid>>allpassword; login(r,allid,allpassword); else break; void cregulator:login(int role,string id,string password) int t=-1;

16、 if(allid=password) cout<<"登陸成功"<<endl; if(role=1) regulator_login(); /管理員登陸 t=1; if(role=2) cuser *person=new cuser(id); while(1) t=person->run_menu(); if(t=3) chan_pwd(id); /修改密碼!返回值為3的話,int run_menu() if(t=0) / 返回值為0,注銷;這個還是用戶自己注銷。 delete person; cout<<"刪除成功&qu

17、ot;<<endl; break; if(t=-1) cout<<"賬號密碼錯誤,請重新輸入"<<endl; string idagain,passwordagain; cin>>idagain>>passwordagain; login(role,idagain,passwordagain); (2)、管理員代碼void cuser:menu() printf(" 1.查看個人信息 n"); printf(" 2.選擇套餐 n"); printf(" 3.修改密碼

18、 n"); printf(" 4.打電話 n"); printf(" 5.發(fā)短信 n"); printf(" 6.在線繳費 n"); printf(" 7.查詢套餐使用情況 n"); printf(" 8.上網(wǎng) n"); printf(" 0.退出 n");int cuser:run_menu() cregulator cr; menu(); int a; cin>>a; if(a=1) cout<<me; run_menu(); if(a=

19、2) select_taocan(); if(a=4) call(); if(a=5) message(); if(a=6) pay(); if(a=7) cout<<mefare; if(a=8) web(); return a; (3)、修改密碼void cregulator:chan_pwd(string id1) cout<<"輸入你的新密碼"<<endl; string temp_password; cin>>temp_password; allid1=temp_password; cout<<"

20、;修改成功"<<endl;(4)、添加用戶void cregulator:add_user() user temp; cout<<"輸入要添加用戶的數(shù)量"<<endl; int num; cin>>num; for(int i=0;i<num;+i) cout<<"輸入新用戶的姓名,手機(jī)號,密碼,身份證號"<<endl; cin>>temp; users.push_back(temp); alltemp.getphone()=temp.getpasswor

21、d(); cout<<"添加成功"<<endl; (5) 、刪除用戶void cregulator:del_user() string temp2; cout<<"請輸入要刪除的手機(jī)號"<<endl; cin>>temp2; for(u=users.begin();u!=users.end();+u) if(u->getphone()=temp2) users.erase(u); all.erase(temp2); / 刪除登陸賬號里面的內(nèi)容 cout<<"刪除成功&

22、quot;<<endl; break; (6) 添加套餐void cregulator:add_taocan() cout<<"請輸入要添加的套餐個數(shù)"<<endl; int num; cin>>num; for(int i=0;i<num;+i) cout<<"輸入套餐代號,每月月租,通話時長,流量,短信條數(shù)"<<endl; cin>>tc; taocans.push_back(tc); cout<<"增加成功"<<en

23、dl; (7) 修改套餐void cregulator:xiugai() double aa,bb,cc,dd,ee;string temp_taocanid; cout<<"輸入修妖修改的套餐代號"<<endl; cin>>temp_taocanid; for(tc_it=taocans.begin();tc_it!=taocans.end();+tc_it) if(tc.gettaocanid()=temp_taocanid) cout<<"將月租修改為"<<endl; cin>>

24、;aa; tc.setyuezu(aa); cout<<"通話時長修改為"<<endl; cin>>bb; tc.setalltime(bb); cout<<"流量為"<<endl; cin>>cc; tc.setgprs(cc); cout<<"短信條數(shù)為"<<endl; cin>>dd; tc.setallduanxin(dd); cout<<"修改成功"<<endl; break

25、; (8) 查找用戶void cregulator:find() cout<<"輸入要查找的手機(jī)號"<<endl; string temp_phone; cin>>temp_phone; for(u=users.begin();u!=users.end();+u) if(u->getphone()=temp_phone) cout<<(*u)<<" "<<endl; break; for(af=allfare.begin();af!=allfare.end();+af) if(

26、af->getuphone()=temp_phone) cout<<(*af); break; (9) 用戶界面void cuser:menu() printf(" 1.查看個人信息 n"); printf(" 2.選擇套餐 n"); printf(" 3.修改密碼 n"); printf(" 4.打電話 n"); printf(" 5.發(fā)短信 n"); printf(" 6.在線繳費 n"); printf(" 7.查詢套餐使用情況 n"

27、;); printf(" 8.上網(wǎng) n"); printf(" 0.刪除賬戶 n");int cuser:run_menu() menu(); int a; cin>>a; switch(a) case(1):cout<<me<<endl;break; case(2):select_taocan();break; case(4):call();break; case(5):message();break; case(6):pay();break; case(7):cout<<mefare<<en

28、dl;break; case(8):web();break; return a;(10) 選擇套餐void cuser:select_taocan() string q; for(tao=vtaocan.begin();tao!=vtaocan.end();+tao) tao->inform(); cout<<"請選擇其中一個套餐,輸入套餐代號"<<endl; cin>>q; for(tao=vtaocan.begin();tao!=vtaocan.end();+tao) if(tao->gettaocanid()=q) me

29、fare.setmoney(mefare.getmoney()-tao->getyuezu(); mefare.setgprs_sy(tao->getgprs(); mefare.settime(tao->getalltime(); mefare.setduanxin(tao->getallduanxin(); ofstream outfile("20143603fare.dat",ios:out|ios:binary); outfile<<mefare; outfile.close(); cout<<"修改成功&q

30、uot;<<endl; break; (11) 打電話void cuser:call() double temp_time; string phoness; cout<<"輸入對方手機(jī)號碼"<<endl; cin>>phoness; cout<<"請輸入入通話時長"<<endl; cin>>temp_time; if(temp_time<=mefare.gettime() mefare.settime(mefare.gettime()-temp_time); cou

31、t<<"通話成功"<<endl; else mefare.setmoney(mefare.getmoney()-(temp_time-mefare.gettime()*mefare.getmoney_minute(); mefare.settime(0.00); cout<<"通話成功"<<endl;ofstream outfile1("20143603fare.dat",ios:out|ios:binary);outfile1<<mefare;outfile1.close(

32、);(12) 發(fā)短信void cuser:message() double temp_tiao; string phones; cout<<"輸入對方手機(jī)號碼"<<endl; cin>>phones; cout<<"輸入所發(fā)短信條數(shù)"<<endl; cin>>temp_tiao; if(temp_tiao<=mefare.getduanxin() mefare.setduanxin(mefare.getduanxin()-temp_tiao); cout<<&quo

33、t;發(fā)送成功"<<endl; else mefare.setmoney(mefare.getmoney()-(temp_tiao-mefare.getduanxin()*mefare.getmoney_tiao(); mefare.setduanxin(0.00); cout<<"發(fā)送成功"<<endl; ofstream outfile2("20143603fare.dat",ios:out|ios:binary); outfile2<<mefare; outfile2.close();(13)

34、 上網(wǎng)void cuser:web() double temp_web; cout<<"輸入上網(wǎng)所用流量"<<endl; cin>>temp_web; if(temp_web<=mefare.getgprs_sy() mefare.setgprs_sy(mefare.getgprs_sy()-temp_web); cout<<"上網(wǎng)成功"<<endl; else mefare.setmoney(mefare.getmoney()-(temp_web-mefare.getgprs_sy()*

35、mefare.getmoney_web(); mefare.setgprs_sy(0.00); cout<<"上網(wǎng)成功"<<endl; ofstream outfile3("220143603fare.dat",ios:out|ios:binary); outfile3<<mefare;outfile3.close();(14) 充值話費void cuser:pay() double temp_money; cout<<"請輸入您要充值的金額"<<endl; cin>&

36、gt;temp_money; mefare.setmoney(mefare.getmoney()+temp_money); cout<<"充值成功"<<endl; ofstream outfile4("220143603fare.dat",ios:out|ios:binary); outfile4<<mefare; outfile4.close(); (15) 管理員登陸后從文件中導(dǎo)入數(shù)據(jù)及向文件中導(dǎo)出數(shù)據(jù)(導(dǎo)入寫在構(gòu)造函數(shù)中,導(dǎo)出寫在析構(gòu)函數(shù)中)cregulator:cregulator() regulator re

37、; ifstream inFile("220143603regulator.dat",ios:in|ios:binary); while(inFile>>re.id>>re.password) allre.id=re.password; inFile.close(); user us; ifstream inFile1("220143603users.dat",ios:in|ios:binary); while(inFile1>>us) users.push_back(us); allus.getphone()=us.

38、getpassword(); inFile1.close(); fare ff; ifstream inFile2("220143603allfare.dat",ios:in|ios:binary); while(inFile2>>ff) allfare.push_back(ff); inFile2.close(); ;cregulator:cregulator() ofstream outFile("220143603allid.dat",ios:out|ios:binary); for(m=all.begin();m!=all.end()

39、;+m) string s1=m->first ,s2=m->second; outFile<<s1<<" "<<s2<<endl; outFile.close(); ofstream outFile1("220143603regulatorDaoChu.dat",ios:out|ios:binary); for(u=users.begin();u!=users.end();+u) outFile1<<(*u); outFile1.close(); ofstream outFile2

40、("220143603taochan.dat",ios:out|ios:binary); for(tc_it=taocans.begin();tc_it!=taocans.end();+tc_it) outFile2<<(*tc_it); outFile2.close(); ofstream outFile3("220143603fare.dat",ios:in|ios:binary); for(af=allfare.begin();af!=allfare.end();+af) outFile3<<(*af); outFile3.

41、close(); (16) 用戶登錄后,從文件中查找到該用戶cuser:cuser(string s_phone) ifstream inFile("220143603users.dat",ios:in|ios:binary); while(inFile>>me) if(me.getphone()=s_phone) break; inFile.close(); ifstream inFile2("220143603fare.dat",ios:in|ios:binary); while(inFile2>>mefare) if(mef

42、are.getuphone()=s_phone) break; inFile2.close(); taocan ab;ifstream inFile3("220143603taocan.dat",ios:in|ios:binary); while(inFile3>>ab) vtaocan.push_back(ab); inFile3.close();(17) 重載的實現(xiàn)ostream & operator <<(ostream&out,const user&use) out<<" "<&l

43、t;<<" "<<use.telephone<<" "<<use.sfz<<" "<<use.password<<endl; return out; istream & operator >>(istream&in,user&use) in>>>>use.telephone>>use.sfz>>use.password; return in; ostream & operator <<(ostream&out,const fare &fa) out<<fa.uphone<<" "<<fa.money<<" "<<fa.time<<" "<<fa.gprs_sy<<&q

溫馨提示

  • 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論