停车场模拟管理系统报告附源代码.docx

上传人:b****6 文档编号:13673705 上传时间:2023-06-16 格式:DOCX 页数:21 大小:330.18KB
下载 相关 举报
停车场模拟管理系统报告附源代码.docx_第1页
第1页 / 共21页
停车场模拟管理系统报告附源代码.docx_第2页
第2页 / 共21页
停车场模拟管理系统报告附源代码.docx_第3页
第3页 / 共21页
停车场模拟管理系统报告附源代码.docx_第4页
第4页 / 共21页
停车场模拟管理系统报告附源代码.docx_第5页
第5页 / 共21页
停车场模拟管理系统报告附源代码.docx_第6页
第6页 / 共21页
停车场模拟管理系统报告附源代码.docx_第7页
第7页 / 共21页
停车场模拟管理系统报告附源代码.docx_第8页
第8页 / 共21页
停车场模拟管理系统报告附源代码.docx_第9页
第9页 / 共21页
停车场模拟管理系统报告附源代码.docx_第10页
第10页 / 共21页
停车场模拟管理系统报告附源代码.docx_第11页
第11页 / 共21页
停车场模拟管理系统报告附源代码.docx_第12页
第12页 / 共21页
停车场模拟管理系统报告附源代码.docx_第13页
第13页 / 共21页
停车场模拟管理系统报告附源代码.docx_第14页
第14页 / 共21页
停车场模拟管理系统报告附源代码.docx_第15页
第15页 / 共21页
停车场模拟管理系统报告附源代码.docx_第16页
第16页 / 共21页
停车场模拟管理系统报告附源代码.docx_第17页
第17页 / 共21页
停车场模拟管理系统报告附源代码.docx_第18页
第18页 / 共21页
停车场模拟管理系统报告附源代码.docx_第19页
第19页 / 共21页
停车场模拟管理系统报告附源代码.docx_第20页
第20页 / 共21页
亲,该文档总共21页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

停车场模拟管理系统报告附源代码.docx

《停车场模拟管理系统报告附源代码.docx》由会员分享,可在线阅读,更多相关《停车场模拟管理系统报告附源代码.docx(21页珍藏版)》请在冰点文库上搜索。

停车场模拟管理系统报告附源代码.docx

停车场模拟管理系统报告附源代码

实训报告

专业:

班级:

学号:

姓名:

课设题目:

停车场模拟管理系统

指导教师:

 

1、需求分析

停车场模拟管理系统现在很多的大型超市等都有智能的停车场当你进入停车场门口就会自动的显示里面还有多少的空位并且指引你走到空的车位停下避免了把车辆开进去并且找不到空的车位和因为车子在停车场内乱走而导致想出来的车没有足够的时间出来。

导致空间和时间各种不必要的麻烦所以急需我们做一个停车场管理系统。

我们的停车场模拟管理系统有以下方面功能:

1

记录进入停车场的车辆的车牌号从而进入后可以知道其所停的停车位。

2

车子离开停车场根据离开时间和进入时间从而计算出所需要交的费用。

3

如果队列已经满了可以让要进入停车场的车子停在旁边的等候队列。

2、总体设计

2.1系统功能概述

(1)

如果选择进入停车场就要判断停车场是否已经满了,如果未满直接进入,如果满了的话就直接排在旁边的便道上等待有车子离开停车场从而进入停车场。

(2)同时改程序还设立多了一个位置以便与有车进入同时有车离开可以停留在这里等候车子离开再进入。

(以防止车子停车场内的车未能离开进入的车又正在进入从而导致停车场堵塞的情况)

(3)离开的时候根据离开的车牌号从而把它从停车场中的位置移开并且通过离开时间和进入停车场的时间来计算出该车子所需要交纳的费用。

有车离开

如果等候队列不为空的话进入停

2.11总体设计图

3、到达停车场准备进入停车场

voidparkingmanagement:

:

arrival(carstack&cs,carqueue&cq,intcnum,doublectime)

{

intpos;

if(!

(cs.full())){到达停车场的车子首先输入其判

intfl(0),i;断停车场是否已经满了如果则直

for(i=0;i<=cs.top;i++){接进入等候车道否则就进入停场

if(cs.s[i].number==cnum){

fl=1;

break;

}

}

if(fl==1)

cout<<"输入错误!

请重新输入!

如果到达的车的车牌号!

=栈内已有车辆的车牌号"<

else{

pos=pushstack(cs,cnum,ctime);//入栈,返回车位信息

cout<<"该停车场还有空位,请到"<

cout<

}

}

else{

pos=pushqueue(cq,cnum,ctime);

cout<<"该停车场已满,请将车停到便道"<

cout<

}

}

3.1进入停车场函数

intparkingmanagement:

:

pushstack(carstack&cs,intcnum,doublectime)

{

if(cs.top==Max-1){

cout<<"停车场已满!

"<

returnMax;

}

else{

cs.top++;

(cs.s[cs.top]).number=cnum;

(cs.s[cs.top]).time=ctime;

return(cs.top+1);

}

}

4、离开停车场

voidparkingmanagement:

:

leave(carstack&cs,carqueue&cq,intcnum,doublectime)

{

inti,flag(0),pstack,count

(1),outcarnum;

doublehour;

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<<"该车在本停车场内停留时间为"<

"<

cs.top--;

}

else

{

p=cq.front;

while(p!

=NULL)//如果所输入的车牌号的车子并不是

{在停车内而是在等候车道内就可

直接开走无需收费

count++;

p=p->next;

if(p->number==cnum){

deletequeue(cq,count);

if(count>Max)

{

cout<<"您的车在便道上的位置为"<

"<

break;

}

}

}

if(p==NULL)cout<<"您的车不在本停车场内,或输入有误,请重新输入!

"<

}

}

 

5、详细设计

5.1函数的调用关系如下图:

主函数

有车离开则进入

判断停车场是否满

full()

满则进入等候队列

图5.11函数调用

5.2主要算法的流程图

 

等候便道

pos=pushqueue(cq,cnum,ctime);

 

 

 

图5.22主要算法图

6、软件说明:

6.1使用环境:

VisualC++6.0.

操作要求:

程序运行后,用户根据所要进行的操作选择是进入停车场还是离开停车场并输入车牌号和时间

6.2测试图:

程序开始运行:

图6.1程序主界面

进入停车场输入选项和车牌号和时间:

 

图6.2进入停车场

离开停车场输入D车牌号时间:

(根据车牌号找到相应的车)

图6.3离开停车场显示结果

7、总结

在这一次的实训中才知道什么叫做真真正正的体会到什么叫做你看得懂程序听得懂课拿着中上的成绩你就口可以说你懂数据结构懂C++懂C了,无数次在修改代码无数次在询问老师问题同学问题,每一次编译错误减少一小个心里乐得跟开了花似的。

非常的感谢同学和老师在QQ上不厌其烦的一次又一次的回答我的问题哪怕是一个马虎的分号的错误。

正所谓勤能补拙往后的我要更加的努力去学习了。

 

附录:

程序代码

#include

usingnamespacestd;

constintMax=10;

constdoubleprice=30;

classcar

{

public:

doubletime;

intnumber;

car*next;

};

classcarstack

{

friendclassparkingmanagement;

public:

carstack();

intempty();

intfull();

car*s;

inttop;

};

carstack:

:

carstack()

{

top=-1;

s=newcar[Max];

if(s==NULL)

{

cout<<"栈空间分配不成功!

"<

exit

(1);

}

}

intcarstack:

:

full(){

returntop==Max-1;

}

classcarqueue

{

friendclassparkingmanagement;

public:

carqueue();

intfull();

car*front,*rear;

};

carqueue:

:

carqueue()

{

rear=front=NULL;

}

classparkingmanagement

{

public:

intpushstack(carstack&cs,intcnum,doublectime);

voidpopstack(carstack&cs,intcnum);

intpushqueue(carqueue&cq,intcnum,doublectime);

intpopqueue(carqueue&cq);

voidarrival(carstack&cs,carqueue&cq,intcnum,doublectime);

voidleave(carstack&cs,carqueue&cq,intcnum,doublectime);

voiddeletequeue(carqueue&cq,inti);

intpopstacknumber;

doublepopstacktime;

};

 

intparkingmanagement:

:

pushstack(carstack&cs,intcnum,doublectime)

{

if(cs.top==Max-1){//Max从1开始,top从0开始

cout<<"停车场已满!

"<

returnMax;

}

else{

cs.top++;

(cs.s[cs.top]).number=cnum;

(cs.s[cs.top]).time=ctime;

return(cs.top+1);}

}

voidparkingmanagement:

:

popstack(carstack&cs,intcnum)

{

inti;

carp;

carstackstemp;

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;

intpopstacknumber()

popstacktime=p.time;

doublepopstacktime()

cs.top--;

while(stemp.top>=0)

cs.s[++(cs.top)]=stemp.s[(stemp.top)--];

}

intparkingmanagement:

:

pushqueue(carqueue&cq,intcnum,doublectime){

car*p,*countp;

intcount

(1);

p=newcar;

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;

}

returncount;

}

intparkingmanagement:

:

popqueue(carqueue&cq)

{

carp;

if(cq.front!

=NULL)

{

p.number=((cq.front)->next)->number;p.time=((cq.front)->next)->time;p.next=((cq.front)->next)->next;

}

returnp.number;

}

voidparkingmanagement:

:

arrival(carstack&cs,carqueue&cq,intcnum,doublectime)

{

intpos;

if(!

(cs.full()))

{

intfl(0),i;

for(i=0;i<=cs.top;i++){

if(cs.s[i].number==cnum)

{fl=1;

break;

}

}

if(fl==1)

cout<<"输入错误!

请重新输入!

如果到达的车的车牌号!

=栈内已有车辆的车牌号"<

Else

{

pos=pushstack(cs,cnum,ctime);//入栈,返回车位信息

cout<<"该停车场还有空位,请到"<

cout<

}

}

Else

{

pos=pushqueue(cq,cnum,ctime);

cout<<"该停车场已满,请将车停到便道"<

cout<

}

}

voidparkingmanagement:

:

leave(carstack&cs,carqueue&cq,intcnum,doublectime)

{

inti,flag(0),pstack,count

(1),outcarnum;

doublehour;

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<<"该车在本停车场内停留时间为"<

"<

cs.top--;

}

else

{

p=cq.front;

while(p!

=NULL)

{

count++;//如果在过道中找到该车,则该车的位置为过道中的第count位置(count从1开始)

p=p->next;

if(p->number==cnum)

{deletequeue(cq,count);

if(count>Max)

{

cout<<"您的车在便道上的位置为"<

"<

break;

}

}

}

if(p==NULL)cout<<"您的车不在本停车场内,或输入有误,请重新输入!

"<

}

}

voidparkingmanagement:

:

deletequeue(carqueue&cq,inti){

car*p,*q;

intj(0);

p=cq.front;

while(p&&j

p=p->next;

j++;

}

if(!

p||!

p->next)cout<<"i不合法";

else{

q=p->next;

p->next=q->next;

deleteq;

}

}

voidprint()

{

cout<<"==================================="<

cout<<"=欢迎光临!

="<

cout<<"=="<

cout<<"=本停车场收费标准为:

30元/小时;车库容量为:

10="<

cout<<"=="<

cout<<"=请输入您的泊车信息:

格式为:

(到达/离去/退出);车牌号;现在时刻="<

cout<<"=其中,A:

到达;D:

离去;E:

退出系统="<

cout<<"==================================="<

}

intmain()

{

characc;

intcarnum;

doublecartime;

parkingmanagementpark;

carstackcars;

carqueuecarq;

while

(1){

print();

cin>>acc>>carnum>>cartime;

if(acc=='A')park.arrival(cars,carq,carnum,cartime);

elseif(acc=='D')park.leave(cars,carq,carnum,cartime);

elseif(acc=='E')break;

else

cout<<"您的输入有误,请重新输入!

"<

}

}

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

当前位置:首页 > 高中教育 > 语文

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2