专 业: 班 级: 学 号: 姓 名:
课设题目: 停车场模拟管理系统 指导教师:
实训报告
目录
一、 需求分析 .......................................................................................... 1 二、 总体设计 .......................................................................................... 1 2.1系统功能概述 ................................................................................ 1 三、 到达停车场准备进入停车场 .......................................................... 2 3.1进入停车场函数 ............................................................................ 3
四、 离开停车场 ...................................................................................... 3 五、 详细设计 .......................................................................................... 6 5.1函数的调用关系 ............................................................................ 6 5.2主要算法的流程图 ........................................................................ 6 六、 软件说明: ...................................................................................... 7 6.1使用环境:Visual C++ 6.0. .......................................................... 8 操作要求:程序运行后,用户根据所要进行的操作选择是进入停车场还是离开停车场并输入车牌号和时间 .......................................... 8 6.2测试图: ........................................................................................ 8 七、 总结 ................................................................................................ 10 附录:程序代码 ...................................................................................... 10
一、需求分析
停车场模拟管理系统现在很多的大型超市等都有智能的停车场当
你进入停车场门口就会自动的显示里面还有多少的空位并且指引你走到空的车位停下避免了把车辆开进去并且找不到空的车位和因为车子在停车场内乱走而导致想出来的车没有足够的时间出来。导致空间和时间各种不必要的麻烦所以急需我们做一个停车场管理系统 。我们的停车场模拟管理系统有以下方面功能: 1
记录进入停车场的车辆的车牌号从而进入后可以知道其所停的停车位。 2
车子离开停车场根据离开时间和进入时间从而计算出所需要交的费用。 3
如果队列已经满了可以让要进入停车场的车子停在旁边的等候队列。
二、总体设计
2.1系统功能概述
(1)
如果选择进入停车场就要判断停车场是否已经满了,如果未满直接进入,如果满了的话就直接排在旁边的便道上等待有车子离开停车场从而进入停车场。
(2)同时改程序还设立多了一个位置以便与有车进入同时有车离开
1
可以停留在这里等候车子离开再进入。(以防止车子停车场内的车未能离开进入的车又正在进入从而导致停车场堵塞的情况)
(3)离开的时候根据离开的车牌号从而把它从停车场中的位置移开
并且通过离开时间和进入停车场的时间来计算出该车子所需要交纳的费用。
系统操作界面
进 离 有车离开 入开 停 停车车 场场
等候队列退出 如果等候队列不为空的话进入停 2.11 总体设计图
三、到达停车场准备进入停车场
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.s[i].number==cnum){ fl=1; break; } } if(fl==1) cout<<\"输入错误!请重新输入!如果到达的车的车牌号!=栈内已有车辆的车牌号\"< pos=pushstack(cs,cnum,ctime);//入栈,返回车位信息 cout<<\"该停车场还有空位,请到\"< int parkingmanagement::pushstack(carstack &cs,int cnum,double ctime) { if(cs.top==Max-1){ cout<<\"停车场已满!\"< 四、离开停车场 void parkingmanagement::leave(carstack &cs,carqueue &cq,int cnum,double ctime) { int i,flag(0),pstack,count(1),outcarnum; double hour; car *p; 3 for(i=0;i<=cs.top;i++) if(flag) { popstack(cs,cnum); hour=ctime-popstacktime; outcarnum=popqueue(cq);/ pstack=pushstack(cs,outcarnum,ctime); if((cs.s[i]).number==cnum) { } flag=1; break; cout<<\"该车在本停车场内停留时间为\"< p=cq.front; while(p!=NULL) //如果所输入的车牌号的车子并不是 cs.top--; { 在停车内而是在等候车道内就可 4 直接开走无需收费 count++; p=p->next; if(p->number==cnum){ deletequeue(cq,count); if(count>Max) { cout<<\"您的车在便道上的位置为\"< if(p==NULL) cout<<\"您的车不在本停车场内,或输入有误,请重新输 } } break; 入!\"< 5 五、详细设计 5.1函数的调用关系 如下图: 主函数 进入停车场 Pushtack函数 数据输入 判断是进入还是离开 Arrival或者leave函数 有车离开则进入 等候便道 满则进入等候队列 pos=pushqueue(cq,cnum,cti判断停车场是否满 me); full() 图5.11 函数调用 5.2主要算法的流程图 6 主程序模块 判断进入还是离开 调到达函数 离开函数 输出模块 图5.22主要算法图 六、软件说明: 7 6.1使用环境:Visual C++ 6.0. 操作要求:程序运行后,用户根据所要进行的操作选择是进入停车场还是离开停车场并输入车牌号和时间 6.2测试图: 程序开始运行: 图 6.1 程序主界面 进入停车场输入选项和车牌号和时间: 8 图6.2 进入停车场 离开停车场输入D 车牌号 时间:(根据车牌号找到相应的车) 图6.3离开停车场显示结果 9 七、总结 在这一次的实训中才知道什么叫做真真正正的体会到什么叫做你看得懂程序听得懂课拿着中上的成绩你就口可以说你懂数据结构懂C++懂C了,无数次在修改代码无数次在询问老师问题同学问题,每一次编译错误减少一小个心里乐得跟开了花似的。非常的感谢同学和老师在QQ上不厌其烦的一次又一次的回答我的问题哪怕是一个马虎的分号的错误。正所谓勤能补拙往后的我要更加的努力去学习了。 附录:程序代码 #include using namespace std; const int Max=10; const double price=30; class car { 10 public: double time; int number; car *next; }; class carstack { friend class parkingmanagement; public: carstack(); int empty(); int full(); car *s; int top; }; carstack::carstack() { top=-1; s=new car[Max]; if(s==NULL) { cout<<\"栈空间分配不成功!\"< 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 { 12 public: int 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 deletequeue(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<<\"停车场已满!\"< else{ cs.top++; (cs.s[cs.top]).number=cnum; (cs.s[cs.top]).time=ctime; return (cs.top+1); } } void parkingmanagement::popstack(carstack &cs,int cnum) { int i; car p; carstack stemp; for(i=0; i<=cs.top; i++) if((cs.s[i]).number==cnum) break; p=cs.s[i]; while(cs.top>i) 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)--]; 14 } int parkingmanagement::pushqueue(carqueue &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; } 15 return 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 &cq,int cnum,double ctime) { int pos; if(!(cs.full())) { int fl(0),i; for(i=0;i<=cs.top;i++){ if(cs.s[i].number==cnum) 16 &cs,carqueue { fl=1; break; } } if(fl==1) cout<<\"输入错误!请重新输入!如果到达的车的车牌号!=栈内已有车辆的车牌号\"< cout<<\"该停车场已满,请将车停到便道\"< } 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.s[i]).number==cnum) { flag=1; break; } if(flag) { popstack(cs,cnum); hour=ctime-popstacktime; outcarnum=popqueue(cq); pstack=pushstack(cs,outcarnum,ctime); cout<<\"该车在本停车场内停留时间为\"< 金额\"< count++;//如果在过道中找到该车,则该车的位置为过道中的第count位置(count从1开始) p=p->next; if(p->number==cnum) { deletequeue(cq,count); if(count>Max) { cout<<\"您的车在便道上的位置为\"< 19 请重新输入!\"< if(!p || !p->next) cout<<\"i不合法\"; else{ q=p->next; p->next=q->next; delete q; } } void print() { cout<<\"= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\"< cout<<\"= 欢迎光临! =\"< char acc; int carnum; double cartime; parkingmanagement park; carstack cars; 21 carqueue carq; while(1){ print(); cin>>acc>>carnum>>cartime; if(acc=='A') park.arrival(cars,carq,carnum,cartime); else park.leave(cars,carq,carnum,cartime); else if(acc=='E') break; else cout<<\"您的输入有误,请重新输入!\"< 22 因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- xiaozhentang.com 版权所有 湘ICP备2023022495号-4
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务