课程设计(论文)-用C++实现水电煤气管理系统.doc

上传人:yyf 文档编号:3292931 上传时间:2019-08-08 格式:DOC 页数:25 大小:547.51KB
返回 下载 相关 举报
课程设计(论文)-用C++实现水电煤气管理系统.doc_第1页
第1页 / 共25页
课程设计(论文)-用C++实现水电煤气管理系统.doc_第2页
第2页 / 共25页
课程设计(论文)-用C++实现水电煤气管理系统.doc_第3页
第3页 / 共25页
课程设计(论文)-用C++实现水电煤气管理系统.doc_第4页
第4页 / 共25页
课程设计(论文)-用C++实现水电煤气管理系统.doc_第5页
第5页 / 共25页
点击查看更多>>
资源描述

《课程设计(论文)-用C++实现水电煤气管理系统.doc》由会员分享,可在线阅读,更多相关《课程设计(论文)-用C++实现水电煤气管理系统.doc(25页珍藏版)》请在三一文库上搜索。

1、课程设计报告课程设计题目:水电煤气管理系统 学生姓名: 专 业: 网络工程班 级: 10211303指导教师: 姜林 2011年 11 月 25 日 东华理工大学课程设计评分表学生姓名: 班级: 学号:课程设计题目:水电煤气管理系统项目内容满分实 评选题能结合所学课程知识、有一定的能力训练。符合选题要求(5人一题)10工作量适中,难易度合理10能力水平能熟练应用所学知识,有一定查阅文献及运用文献资料能力10理论依据充分,数据准确,公式推导正确10能应用计算机软件进行编程、资料搜集录入、加工、排版、制图等10能体现创造性思维,或有独特见解10成果质量总体设计正确、合理,各项技术指标符合要求。10

2、说明书综述简练完整,概念清楚、立论正确、技术用语准确、结论严谨合理;分析处理科学、条理分明、语言流畅、结构严谨、版面清晰10设计说明书栏目齐全、合理,符号统一、编号齐全。格式、绘图、表格、插图等规范准确,符合国家标准10有一定篇幅,字符数不少于500010总 分100指导教师评语: 指导教师签名: 年 月 日一 问题描述:设计一个水电管理信息系统,能够对高校的水电费用进行管理,包括了登记费用,查询费用,以及住户信息管理等。在设计时要考虑到学生和教工在用水电时的不同,学生可以免费使用一定额度的水电,超过这个额度的随便以后必须自费使用,且自费部分水电费的价格标准要高于教工的收费标准(主要是节约资源

3、)。二 设计思路:(一)程序功能:1.实现对用户信息的录入2.实现水电煤气数据的录入3.计算并查询用户应缴费用4.查询未缴纳费用名单(二)程序说明:1.在主函数中通过分支选择可以跳转不同的功能选项进而实现2.在显示主菜单函数中,我们通过设计友好界面来与用户进行交互。在“请选择相应功能(0-4):”中使用者输入非0-4数字或其他字符时,系统提示“请检查您输入的数字在04之间!请在输入一遍!”的信息,以帮助用户进行正确选择。3.首先建立了User类,用于初始化身份证号码、姓名、用水电、煤气量,又定义了缴费函数setMonery(),用在有人缴费的函数体中,从键盘输入缴的费用,一开始我们在setMo

4、ney(),中没有对缴的费用进行累加,在查询信息时现实的应缴费用不正确,经过我们的努力,检查出错误并加以改正,让程序更加完善。4.用User类派生出Student和|Teacher类,其中有计算应该缴的费用,Student类比Teacher类多了免费。5.在保存文件的处理中,需考虑到“创建保存文件失败!”和“已成功保存文件!”等诸多内容。 (三)文件类型: (1) Constant.h 用于存放收费标准。(2) File.cpp 该文件中有两个类:1. StuFile类,主要用于对学生信息的操作 函数属性注释PublicStuFile()构造函数Publicvoid add(Student &

5、s)将S添加到文件中Publicvoid display()依次显示所有的学生的信息PublicStudent*gerStudent(string id)得到学号为id的学生的对象指针PublicStuFile()析构函数,释放资源,并把数组中的信息存进文件Publicvoid wjf()未缴费的学生的名单Privatevector*stuList;学生信息的向量数组,用于保存所有学生的信息2 TeacherFile 类,主要用于对教工信息的操作PublicTeacherFile()构造函数Publicvoid add(Teacher&s)将s添加到文件中Publicvoid display(

6、)依次显示所有的教师信息PublicTeacher *getTeacher(string id)得到编号为id的教师的对象指针PublicTeacherFile()析构函数,释放资源,并把数组中的信息存进文件Publicvoid wjf()未交费的教工人员名单PrivateVector*teaLisr教工的向量数组,用于保存所有教工的信息 (3)Main.cpp函数属性注释void init()新建一个学生或者教工的信息void select()查询界面,根据用户的输入来显示用户想查询的信息void add()信息的录入,录入学生或者教工的水电煤气信息void handed()缴费,有学生或者

7、教工缴费的时候调用此函数int mainMenu()主菜单,显示一个菜单,返回用户的输入void work()程序开始工作int main()主函数,程序的入口 (4)Student.cpp Class Student:virtual public User函数属性注释PublicStudent():User(“”,”,0,0,0)构造函数PublicStudent(string i,string n,Float w=0,float p=0,float g=0):User(i,n,w,p,g)构造函数 i:学号n:姓名Publicvoid display()依次显示所有的学生的信息Public

8、float display()返回学生应缴的费用Privatefloat freeWater;学生免费使用的水量Privatefloat freePower;学生免费使用的电量Privatefloat freeGas;学生免费使用的煤气量Privatefloat money;缴费 (5)Teacher.cpp Class Teacher:virtual public User函数属性注释PublicTeacher(string i,string n,float w=0,float p=0,floatg=0):User(I,n,w,p,g)构造函数Publicvoid display()依次显示

9、所有的教工信息Publicfloat getMoney()返回教工应缴的费用 (6)User.cpp函数属性注释PublicUser(string i,string n,float w=0,float p=0,float g=0)构造函数Publicstring getId()获取编号Publicstring getName()获取姓名Publicvoid setId(string i)设置编号Publicvoid setName(string n)设置姓名Publicvoid setWater(float w)设置水量Publicvoid setPower(float p)设置电量Publi

10、cvoid setGas(float g)设置煤气量Publicfloat getWater()使用水量Publicvirtual void display()=0;依次显示所有信息Publicvoid setMoney(float m)缴费Publicvirtual float getMoney()=0;应缴费用(四)UML图:StuFile+id:string+name:string+useWater:float+usePower:float+useGas:float+money:float+add():void+display():void+wjf():voidStudent-freeW

11、ater:float-freePower:float-freeGas:float+display():void+getMoney():voidUser+i:string+n:string+w:float+p:float+g:float+getId():string+getName():string+setId(string i) :string+setName(string n) :string+setWater(float w) :float+setPower(float p) :float+setGas(float g) :float+getWater():float 三 程序代码:Con

12、stant.h/收费标准#ifndef Constant#define Constant/教师const static float TwaterUnit=1;const static float TpowerUnit=1;const static float TgasUnit=1;/学生const static float SwaterUnit=1;const static float SpowerUnit=1;const static float SgasUnit=1;/保存学生信息的文件const static char* stuFlieName=s.txt;/保存教师信息的文件const

13、 static char* teaFileName=t.txt;#endifMain.cpp#include#include#include#include#includeStudent.cpp#includeTeacher.cpp#includeFile.cppusing namespace std;void init()coutendl;cout1.新建教工信息n2.新建学生信息nendl;cout请选择你要进行的操作:o;if(o=1)string id;string name;coutid;coutname;Teacher t(id,name);TeacherFile tf;tf.ad

14、d(t);else if(o=2)string id;string name;coutid;coutname;Student s(id,name);StuFile sf;sf.add(s);elsereturn ;void select()coutendl;cout1.学生的信息n2.教师的信息n3.按身份证号查询n4.未缴费的人员名单n5.不进行任何的操作nendl;couto;StuFile sf;TeacherFile tf;if(o=1)cout该用户的信息是:endl;cout|setw(18)身份证号| setw(8)姓名| setw(8)用水量| setw(8)用电量| setw

15、(8)用煤气量| setw(8)要缴的费用endl;sf.display();else if(o=2)cout该用户的信息是:endl;cout|setw(18)身份证号| setw(8)姓名| setw(8)用水量| setw(8)用电量| setw(8)用煤气量| setw(8)要缴的费用endl;tf.display();else if(o=3)User *user;StuFile sf;TeacherFile tf;string id;coutid;user=sf.getStudent(id);if(user=0)user=tf.getTeacher(id);if(user=0)cou

16、t资料库中没有该身份证号的用户!endl;return ;cout该用户的信息为:endl;cout|setw(18)身份证号| setw(8)姓名| setw(8)用水量| setw(8)用电量| setw(8)用煤气量| setw(8)要缴的费用display();else if(o=4)sf.wjf();tf.wjf();elsereturn ;void add()cout1.对教工使用的水电煤气信息的录入endl2.对学生使用的水电煤气信息的录入endl3.不进行任何操作endl;cout请输入你要进行的操作:o;string id;float water;float power;fl

17、oat gas;if(o=1|o=2)User*user;StuFile sf;TeacherFile tf;coutid;user=sf.getStudent(id);if(user=0)user=tf.getTeacher(id);if(user=0)cout资料库中没有该身份证号的用户!endl;return ;cout该用户的信息是:endl;cout|setw(18)身份证号| setw(8)姓名| setw(8)用水量| setw(8)用电量| setw(8)用煤气量| setw(8)要缴的费用display();coutwater;coutpower;coutgas;user-s

18、etWater(water);user-setPower(power);user-setGas(gas);elsereturn ;void handed()coutid;User*user;StuFile sf;TeacherFile tf;user=sf.getStudent(id);if(user=0)user=tf.getTeacher(id);if(user=0)cout资料库中没有该身份证号的用户!endl;return ;cout该用户的信息是:endl;cout|setw(18)身份证号| setw(8)姓名| setw(8)用水量| setw(8)用电量| setw(8)用煤气

19、量| setw(8)要缴的费用display();coutmoney;user-setMoney(money);cout缴费成功n;int mainMenu()coutendlendl;cout endl;cout endl;cout 水电煤气管理系统 endl;cout endl;cout endl;coutendl;cout 1.新建用户信息endl;cout 2.信息查询endl;cout 3.信息的录入endl;cout 4.有人缴费endl;cout 0.退出系统endl;int a;char c20;docout 请选择相应的功能(0-4):endl;couta;gets(c);i

20、f(a4)coutendlendl;cout请确认您输入的数字在04之间!endl;cout请重新输入一遍!endlendl;while(a4);return a;void work()switch(mainMenu()case 1:init();break;case 2:select();break;case 3:add();break;case 4:handed();break;default:break;void Menu()coutendl;cout endl;cout endl;cout 水电煤气管理系统 endl;cout endl;cout 杨振坡 endl;cout endl;

21、cout endl;coutendl;system(pause);system(cls);void main()system(color 3A);Menu();char a=y;while(a=y)work();cout是否继续使用该系统(y/n)a;File.cpp/StuFile类,对学生信息的操作/TeacherFile类,对教工信息的操作#include#include#include#include#include#includeStudent.cpp #includeTeacher.cpp#includeUser.cpp#includeConstant.h#ifndef StuFi

22、le_class#define StuFile_classclass StuFilevector *stuList;public :string id;string name;float useWater;float usePower;float useGas;float money;StuFile()stuList=new vector;ifstream *is=new ifstream(StuFileName,ios_base:in);if(is=0)cout打开文件失败!good()Student s(,);is-read(char*)&s,sizeof(Student);if(s.ge

23、tId() !=)stuList-push_back(s);is-close();void add(Student &s)stuList-push_back(s);void display()for(int i=0;isize();i+)Student s=stuList-at(i);s.display();Student *getStudent(string id)for(int i=0;isize();i+)if(stuList-at(i).getId()=id)return &stuList-at(i);return 0;StuFile()if(stuList !=NULL & !stu

24、List-empty()ofstream os(stuFileName,ios_base:out);for(int i=0;isize();i+)if(stuList-at(i).getId() !=)os.write(char*)&stuList-at(i),sizeof(Student);os.close();delete stuList;void wjf()cout未缴费的学生名单:endl;for(int i=0;isize();i+)Student s=stuList-at(i);if(s.getMoney()0)cout该学生的信息是:endl;cout|setw(18)身份证号|

25、 setw(8)姓名| setw(8)用水量| setw(8)用电量| setw(8)用煤气量| setw(8)要缴纳的费用endl;s.display();#endif#ifndef TeaFile_class#define TeaFile_classclass TeacherFilevector *teaList;public:TeacherFile()teaList=new vector;ifstream*is=new ifstream(teaFileName,ios_base:in);if(is=0)cout打开文件失败!good()Teacher s(,);is-read(char*

26、)&s,sizeof(Teacher);if(s.getId() !=)teaList-push_back(s);is-close();Teacher *getTeacher(string id)for(int i=0;isize();i+)if(teaList-at(i).getId()=id)return &teaList-at(i);return 0;void wjf()cout教工未缴费的人员名单:endl;for(int i=0;isize();i+)Teacher t=teaList-at(i);if(t.getMoney()0)cout该教师的信息是:endl;cout|setw

27、(18)身份证号| setw(8)姓名| setw(8)用水量| setw(8)用电量| setw(8)用煤气量| setw(8)要缴的费用endl;t.display();void display()for(int i=0;isize();i+)Teacher t=teaList-at(i);t.display();void add(Teacher &s)teaList-push_back(s);TeacherFile()if(teaList !=NULL & !teaList-empty()ofstream os(teaFileName,ios_base:out);for(int i=0;

28、isize();i+)if(teaList-at(i).getId() !=)os.write(char*)&teaList-at(i),sizeof(Teacher);os.close();delete teaList;#endifStudent.cpp#ifndef STUDENT_CLASS#define STUDENT_CLASS#include#include#include#includeConstant.h#includeUser.cppusing namespace std;class Student:virtual public Userprivate :float free

29、Water;float freePower;float freeGas;public :Student():User(,0,0,0)freeWater=1;freePower=2;freeGas=3;Student(string i,string n,float w=0,float p=0,float g=0):User(i,n,w,p,g)void display()cout|setw(18)id| setw(8)name| setw(8)useWater| setw(8)usePower| setw(8)useGas| setw(8)getMoney()freeWater)?(useWat

30、er-freeWater):0);float p=SpowerUnit*(usePowerfreePower)?(usePower-freePower):0);float g=SgasUnit*(useGasfreeGas)?(useGas-freeGas):0);return w+p+g-money;#endifTeacher.cpp#includeUser.cpp#includeConstant.h#ifndef Teacher_class#define Teacher_classclass Teacher:virtual public Userpublic :Teacher(string

31、 i,string n,float w=0,float p=0,float g=0):User(i,n,w,p,g)void display()cout|setw(18)id| setw(8)name| setw(8)useWater| setw(8)usePower| setw(8)useGas| setw(8)getMoney()endl;float getMoney()float w=TwaterUnit* useWater;float p=TpowerUnit* usePower;float g=TgasUnit* useGas;return w+p+g-money;#endifUser.cpp#include#include#includeusing namespace std;#ifndef USER_CLASS#define USER_CL

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 研究报告 > 信息产业


经营许可证编号:宁ICP备18001539号-1