版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、程序设计综合实习总结报告 设计题目:手机资费管理系统 实验地点:山东农业大学本部文理大楼实验室 完成起止日期: 2015.8.31-2015.9.6目录一、设计思路 3二、具体实现 4 1、数据类 4 2、操作类 6 3、具体代码 7 三、测试数据设计 18四、运行调试 19 1、用户 19 2、管理员 23 五、设计体会与小结 25 三、 设计思路手机资费管理系统分为管理员和用户两个登陆板块,管理员负责资费标准、资费套餐及用户信息的管理;用户模块包括套餐的选择、缴费、业务模拟(打电话、发短信、上网)、余额查询、费用详单查询等。系统类设计分为数据类和操作类,数据类有管理员类,用户类,资费类,套
2、餐类;操作类对数据类中的数据进行操作。该系统的用户信息,套餐信息等都是通过外部文件导入到程序中,并输出外部文件中,同时管理员也可实时增加用户,套餐等,并输出到文件中。用户界面:查看个人信息;选择套餐;修改密码;打电话;发短信;在线缴费;查询套餐使用情况;上网。管理员:添加用户;删除用户;添加套餐;修改套餐;查找用户。四、 具体实现1、数据类(1) 、用户数据类 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) 、管理员数据类class regulatorpublic: string password,id; r
4、egulator() regulator();(3) 、资费数据类class fare private: string uphone; double money; /余额 double time; /剩余通话时长 double gprs_sy;/流量余额 double duanxin;/短信条数 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<<"剩余短信条数为"<&
7、lt;duanxin<<"超出套餐后,每分钟通话时间价格为"<<money_minute<<"超纯套餐后,每条短信的价格为"<<money_tiao<<endl; friend ostream& operator<<(ostream&out,const fare &fa); friend istream& operator>>(istream&in,fare&fa); ;(4) 、套餐数据类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<<"每月基础流量为"<<gprs<<&q
10、uot;每月免费短信条数为"<<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();/发短信 void select_taocan(); /选择套餐 void pay() ;/在线缴费 void web(); /上网;(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(" 欢迎登录手机资费管理系统 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.发短信 n"); printf(" 6.在线缴费 n"); printf(" 7.查询套餐使用情况 n"); printf(" 8.上网 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<<"输入要添加用户的数量"<<endl; int num; cin>>num; for(int i=0;i<num;+i) cout<<"输入新用户的姓名,手机号,密码,身份证号"<<endl; cin>>temp; users.push_back(temp); alltemp.getphone()=temp.getpasswor
21、d(); cout<<"添加成功"<<endl; (5) 、删除用户void cregulator:del_user() string temp2; cout<<"请输入要删除的手机号"<<endl; cin>>temp2; for(u=users.begin();u!=users.end();+u) if(u->getphone()=temp2) users.erase(u); all.erase(temp2); / 删除登陆账号里面的内容 cout<<"删除成功&
22、quot;<<endl; break; (6) 添加套餐void cregulator:add_taocan() cout<<"请输入要添加的套餐个数"<<endl; int num; cin>>num; for(int i=0;i<num;+i) cout<<"输入套餐代号,每月月租,通话时长,流量,短信条数"<<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<<"短信条数为"<<endl; cin>>dd; tc.setallduanxin(dd); cout<<"修改成功"<<endl; break
25、; (8) 查找用户void cregulator:find() cout<<"输入要查找的手机号"<<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.发短信 n"); printf(" 6.在线缴费 n"); printf(" 7.查询套餐使用情况 n"
27、;); printf(" 8.上网 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<<"输入对方手机号码"<<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) 发短信void cuser:message() double temp_tiao; string phones; cout<<"输入对方手机号码"<<endl; cin>>phones; cout<<"输入所发短信条数"<<endl; cin>>temp_tiao; if(temp_tiao<=mefare.getduanxin() mefare.setduanxin(mefare.getduanxin()-temp_tiao); cout<<&quo
33、t;发送成功"<<endl; else mefare.setmoney(mefare.getmoney()-(temp_tiao-mefare.getduanxin()*mefare.getmoney_tiao(); mefare.setduanxin(0.00); cout<<"发送成功"<<endl; ofstream outfile2("20143603fare.dat",ios:out|ios:binary); outfile2<<mefare; outfile2.close();(13)
34、 上网void cuser:web() double temp_web; cout<<"输入上网所用流量"<<endl; cin>>temp_web; if(temp_web<=mefare.getgprs_sy() mefare.setgprs_sy(mefare.getgprs_sy()-temp_web); cout<<"上网成功"<<endl; else mefare.setmoney(mefare.getmoney()-(temp_web-mefare.getgprs_sy()*
35、mefare.getmoney_web(); mefare.setgprs_sy(0.00); cout<<"上网成功"<<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) 管理员登陆后从文件中导入数据及向文件中导出数据(导入写在构造函数中,导出写在析构函数中)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) 重载的实现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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 企业新员工入职培训考核试题及参考答案
- 2026-2027学年江苏省盐城市东台市第六教育联盟九年级(上)期中道德与法治试卷(含答案)
- 陕西榆林市部分校2026-2027学年高三上学期12月期中考试 化学+答案
- 亚马逊计算机面试题及详细答案
- 高中化学教学设计:第三章微项目自制米酒-领略传统酿造工艺魅力
- 初中七年级地理教学设计:美国-自然环境与经济发展的区域关联
- 第五单元-《三沙谣》教学设计-2026-2027学年湘艺版(新教材)初中音乐八年级上册
- 九年级物理液体压强专题复习教学设计
- 出租车司机从业资格考试题及答案
- 小学五年级道德与法治《传统美德 源远流长》第一、二课时教学设计
- 2026年“美丽中国”第七届全国国家版图知识竞赛(中小学组)考试题库(新版)
- 输变电工程施工质量验收统一表式附件1:线路工程填写示例
- 2026年给排水工程师专业知识测试试卷(含答案)
- 江苏事业单位文秘岗笔试专项训练题库含答案
- 沼气净化提纯设计计算书(含甲烷回收)
- LCTG 2026-017 植物新品种特异性、一致性和稳定性测试指南 芦竹属
- 中国心理卫生协会心理咨询师初级章节练习题库
- 5.1.1 生物与环境的相互作用 课件 (共24张) 人教版(2024)八年级上册
- (2026年)口服抗栓药物相关消化道损伤防治专家共识深入解读
- 2026年江苏省高考地理试卷(含答案及解析)
- 2026年郑州电力高等专科学校单招职业技能测试题库附答案详解
评论
0/150
提交评论