1、停车场模拟管理系统报告附源代码 实训报告专 业:班 级:学 号:姓 名:课设题目: 停车场模拟管理系统 指导教师:一、需求分析 停车场模拟管理系统现在很多的大型超市等都有智能的停车场当你进入停车场门口就会自动的显示里面还有多少的空位并且指引你走到空的车位停下避免了把车辆开进去并且找不到空的车位和因为车子在停车场内乱走而导致想出来的车没有足够的时间出来。导致空间和时间各种不必要的麻烦所以急需我们做一个停车场管理系统 。我们的停车场模拟管理系统有以下方面功能:1记录进入停车场的车辆的车牌号从而进入后可以知道其所停的停车位。2车子离开停车场根据离开时间和进入时间从而计算出所需要交的费用。3如果队列已
2、经满了可以让要进入停车场的车子停在旁边的等候队列。二、总体设计2.1系统功能概述(1)如果选择进入停车场就要判断停车场是否已经满了,如果未满直接进入,如果满了的话就直接排在旁边的便道上等待有车子离开停车场从而进入停车场。(2)同时改程序还设立多了一个位置以便与有车进入同时有车离开可以停留在这里等候车子离开再进入。(以防止车子停车场内的车未能离开进入的车又正在进入从而导致停车场堵塞的情况)(3)离开的时候根据离开的车牌号从而把它从停车场中的位置移开并且通过离开时间和进入停车场的时间来计算出该车子所需要交纳的费用。 有车离开 如果等候队列不为空的话进入停 2.11 总体设计图三、到达停车场准备进入
3、停车场void parkingmanagement:arrival(carstack &cs,carqueue &cq,int cnum,double ctime) int pos;if(!(cs.full() 到达停车场的车子首先输入其判 int fl(0),i; 断停车场是否已经满了如果则直 for(i=0;i=cs.top;i+) 接进入等候车道否则就进入停场 if(cs.si.number=cnum) fl=1; break; if(fl=1) cout输入错误!请重新输入!如果到达的车的车牌号!=栈内已有车辆的车牌号endl; else pos=pushstack(cs,cnum,c
4、time);/入栈,返回车位信息 cout该停车场还有空位,请到pos号车位进行泊车endl; coutendl; else pos=pushqueue(cq,cnum,ctime); cout该停车场已满,请将车停到便道pos号车位上endl; coutendl; 3.1进入停车场函数 int parkingmanagement:pushstack(carstack &cs,int cnum,double ctime) if(cs.top=Max-1) cout停车场已满!endl; return Max; else cs.top+; (cs.scs.top).number=cnum; (c
5、s.scs.top).time=ctime; return (cs.top+1); 四、离开停车场void parkingmanagement:leave(carstack &cs,carqueue &cq,int cnum,double ctime) int i,flag(0),pstack,count(1),outcarnum; double hour; car *p; for(i=0;i=cs.top;i+) if(cs.si).number=cnum) flag=1; break; if(flag) popstack(cs,cnum); hour=ctime-popstacktime;
6、outcarnum=popqueue(cq);/pstack=pushstack(cs,outcarnum,ctime); cout该车在本停车场内停留时间为hour分钟,应付金额hour*(price/60)元!next; if(p-number=cnum) deletequeue(cq,count); if(countMax) cout您的车在便道上的位置为count号车位,请自行驶离,无需付费!endl; break; if(p=NULL) cout您的车不在本停车场内,或输入有误,请重新输入!endl; 五、详细设计5.1函数的调用关系 如下图: 有车离开则进入 满则进入等候队列 图5
7、.11 函数调用5.2主要算法的流程图图5.22主要算法图六、软件说明:6.1使用环境:Visual C+ 6.0.操作要求:程序运行后,用户根据所要进行的操作选择是进入停车场还是离开停车场并输入车牌号和时间6.2测试图:程序开始运行: 图 6.1 程序主界面进入停车场输入选项和车牌号和时间:图6.2 进入停车场离开停车场输入D 车牌号 时间:(根据车牌号找到相应的车)图6.3离开停车场显示结果 七、总结在这一次的实训中才知道什么叫做真真正正的体会到什么叫做你看得懂程序听得懂课拿着中上的成绩你就口可以说你懂数据结构懂C+懂C了,无数次在修改代码无数次在询问老师问题同学问题,每一次编译错误减少一
8、小个心里乐得跟开了花似的。非常的感谢同学和老师在QQ上不厌其烦的一次又一次的回答我的问题哪怕是一个马虎的分号的错误。正所谓勤能补拙往后的我要更加的努力去学习了。附录:程序代码#includeusing namespace std; const int Max=10;const double price=30;class car public: double time; int number; car *next;class carstack friend class parkingmanagement; public: carstack(); int empty(); int full();
9、car *s; int top;carstack:carstack() top=-1; s=new carMax; if(s=NULL) cout栈空间分配不成功!endl; exit(1); int carstack:full() return top=Max-1;class carqueue friend class parkingmanagement; public: carqueue(); int full(); car *front,*rear;carqueue:carqueue() rear=front=NULL;class parkingmanagement public: in
10、t pushstack(carstack &cs,int cnum,double ctime); void popstack(carstack &cs,int cnum); int pushqueue(carqueue &cq,int cnum,double ctime); int popqueue(carqueue &cq); void arrival(carstack &cs,carqueue &cq,int cnum,double ctime); void leave(carstack &cs,carqueue &cq,int cnum,double ctime); void delet
11、equeue(carqueue &cq,int i); int popstacknumber; double popstacktime;int parkingmanagement:pushstack(carstack &cs,int cnum,double ctime) if(cs.top=Max-1)/Max从1开始,top从0开始 cout停车场已满!endl; return Max; else cs.top+; (cs.scs.top).number=cnum; (cs.scs.top).time=ctime; return (cs.top+1); void parkingmanagem
12、ent:popstack(carstack &cs,int cnum) int i; car p; carstack stemp; for(i=0; ii) stemp.s+(stemp.top)=cs.s(cs.top)-; popstacknumber=p.number;int popstacknumber() popstacktime=p.time;double popstacktime() cs.top-; while(stemp.top=0) cs.s+(cs.top)=stemp.s(stemp.top)-;int parkingmanagement:pushqueue(carqu
13、eue &cq,int cnum,double ctime) car *p,*countp; int count(1); p=new car; p-number=cnum; p-time=ctime; p-next=NULL; if (cq.front=NULL) cq.front=cq.rear=p; else p-next=(cq.rear)-next; (cq.rear)-next=p; cq.rear=(cq.rear)-next; countp=(cq.front)-next; while(countp!=NULL) count+; countp=countp-next; retur
14、n count;int parkingmanagement:popqueue(carqueue &cq) car p; if(cq.front!=NULL) p.number=(cq.front)-next)-number; p.time=(cq.front)-next)-time; p.next=(cq.front)-next)-next; return p.number;void parkingmanagement:arrival(carstack &cs,carqueue &cq,int cnum,double ctime) int pos; if(!(cs.full() int fl(
15、0),i; for(i=0;i=cs.top;i+) if(cs.si.number=cnum) fl=1; break; if(fl=1) cout输入错误!请重新输入!如果到达的车的车牌号!=栈内已有车辆的车牌号endl; Else pos=pushstack(cs,cnum,ctime);/入栈,返回车位信息 cout该停车场还有空位,请到pos号车位进行泊车endl; coutendl; Else pos=pushqueue(cq,cnum,ctime); cout该停车场已满,请将车停到便道pos号车位上endl; coutendl; void parkingmanagement:l
16、eave(carstack &cs,carqueue &cq,int cnum,double ctime) int i,flag(0),pstack,count(1),outcarnum; double hour; car *p; for(i=0;i=cs.top;i+) if(cs.si).number=cnum) flag=1; break; if(flag) popstack(cs,cnum); hour=ctime-popstacktime; outcarnum=popqueue(cq); pstack=pushstack(cs,outcarnum,ctime); cout该车在本停车
17、场内停留时间为hour分钟,应付金额hour*(price/60)元!next; if(p-number=cnum) deletequeue(cq,count); if(countMax) cout您的车在便道上的位置为count号车位,请自行驶离,无需付费!endl; break; if(p=NULL) cout您的车不在本停车场内,或输入有误,请重新输入!endl; void parkingmanagement:deletequeue(carqueue &cq,int i) car *p,*q; int j(0); p=cq.front; while(p & jnext; j+; if(!
18、p | !p-next) coutnext; p-next=q-next; delete q; void print() cout= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =endl; cout= 欢迎光临! =endl; cout= =endl; cout= 本停车场收费标准为:30元/小时;车库容量为:10 =endl; cout= =endl; cout= 请输入您的泊车信息:格式为:(到达/离去/退出);车牌号;现在时刻 =endl; cout= 其中,A:到达;D:离去;E:退出系统 =endl; cout= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =acccarnumcartime; if(acc=A) park.arrival(cars,carq,carnum,cartime); else if(acc=D) park.leave(cars,carq,carnum,cartime); else if(acc=E) break; else cout您的输入有误,请重新输入!endl;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1