停车场管理系统程序的设计说明.docx
- 文档编号:23855869
- 上传时间:2023-05-21
- 格式:DOCX
- 页数:24
- 大小:507.45KB
停车场管理系统程序的设计说明.docx
《停车场管理系统程序的设计说明.docx》由会员分享,可在线阅读,更多相关《停车场管理系统程序的设计说明.docx(24页珍藏版)》请在冰豆网上搜索。
停车场管理系统程序的设计说明
一、停车场管理系统
1.1设计要求
1.1.1问题描述
设计一个停车场管理系统,模拟停车场的运作,此程序具有以下功能:
1汽车到达,则显示汽车在停车场或便道上的停车位置。
2若车离去,则显示汽车在停车场停留的时间和应缴纳的费用(在便道上停留的时间不收费)。
1.1.2基本要求
①要求以栈模拟停车场,以队列模拟车场外地便道,按照从终端读入的输入数据序列进行模拟管理。
2求处理的数据元素包括三个数据项:
汽车“到达”或“离去”信息。
汽车牌照以与离去的时刻。
3要求栈以顺序结构实现,队列以链表实现。
1.1.3测试数据
自行设计一组在停车场上停车的数据和便道上停车的数据。
1.1.4实现提示
该停车场能容纳车辆的数量,便道上的停车数量。
车辆到达对应栈的入栈操作,车辆离开对应栈的出栈操作。
1.2设计代码与注释
#include
#include
#include
#include
#include
usingnamespacestd;
#definePASS20
#definePOT20
structpassLot//便道队列数据结构
{
intnum;//车位号
time_ttimep;//停车时间
intcarNum;//停车的车牌
};
structpotLot//停车场栈数据结构
{
intnum;
time_ttimep;
intcarNum;
};
voidprintLine()//打印下划线(作为主界面图表的框架)
{
cout<<"\t\t\t___________________________________"< return; } voidprintStar()//打印星号 { cout< } classerroFull//停车位满时异常类 {public: erroFull() { system("color3c"); } voidex() { cout< ! ! 停车场位已满! "< _sleep(2000); } ~erroFull(){} }; classerroEmp//停车位空时异常类 {public: erroEmp() { system("color3c"); } voidex() { cout<<"! ! ! 停车场位为空! "< _sleep(2000); } ~erroEmp(){} }; classparkingLot//停车场类 { public: parkingLot() { passLot*pa;//便道停车位指针 potLot*po;//停车场停车位指针 flag=0;//用来记忆队列(便道)中停车的数量 rear=front=0;//初始化队列头尾 base=0; top=base;//初始化栈头尾 inti=0;//初始化停车场和便道空间以与车位号 for(;i { pa=(passLot*)malloc(sizeof(passLot)); a[i]=pa; a[i]->num=i+1; a[i]->carNum=0; po=(potLot*)malloc(sizeof(potLot)); b[i]=po; b[i]->num=i+1; b[i]->carNum=0; } } ~parkingLot() { cout<<"\t\t停车场数据已清空。 "< } voidpassLG()//便道管理函数 { try { if(flag==20)throwerroFull();//如果停车位已满,则抛出车位慢得异常情况 system("cls"); printStar(); cout<<"\t\t\t\t您进入了便道停车界面"< cout< "< cout<<"\t\t\t请输入将要停车的: "; cin>>a[rear]->carNum; a[rear]->timep=time(NULL); cout< ! 汽车停放在"<num<<"车位成功,系统将在一秒后返回上层界面! ! "< rear=(rear+1)%PASS; flag++; _sleep(1000); } catch(erroFull&err) { err.ex(); } } voidpotLG()//停车场管理函数 { try { if(top==20)throwerroFull(); system("cls"); printStar(); cout<<"\t\t\t\t您进入了停车场停车界面"< cout< "< cout<<"\t\t\t请输入将要停车的: "; cin>>b[top]->carNum; b[top]->timep=time(NULL); cout< ! 汽车停放在"<num<<"车位成功,系统将在一秒后返回上层界面! ! "< top++; _sleep(1000); } catch(erroFull&err) { err.ex(); } } voidarrive()//汽车到达 { intchoice=-1; if(top==20&&flag==20)throwerroFull(); for(;;) { system("cls"); printStar(); cout<<"\t\t\t\t欢迎进入停车场"< printLine(); cout<<"\t\t\t|1.停车场停车\t\t\t|"< printLine(); cout<<"\t\t\t|2.便道停车\t\t\t|"< printLine(); cout<<"\t\t\t|3.返回\t\t\t|"< printLine(); printStar(); cout<<"\t\t请输入你的选项: "; cin>>choice; switch(choice) { case1: potLG();break; case2: passLG();break; case3: break; default: system("color3c");cout< "< _sleep(1000);break; } if(choice==3)break; } return; } intfeep(time_t*tmp)//费用计算 { intgap=0,m=0,hour=0,min=0,sec=0;//设置数据用来计算时间间隔,停车时、分、秒。 local=localtime(tmp);//将存储的时间转化为当地时间日历 cout< "< " < hour=local->tm_hour;//保存停车时刻 min=local->tm_min; sec=local->tm_sec; now=time(NULL); nowp=localtime(&now); cout<<"\t当前时间为: "< "< " < hour=nowp->tm_hour-hour;//求出停车的时间间隔 min=nowp->tm_min-min; sec=nowp->tm_sec-sec; if(sec<0){min--;sec=60+sec;}//进行秒、分钟、秒时间转换 if(min<0){hour--;min=60+min;} cout<<"\t汽车共停了"< if((0! =min)||(0! =sec))m=1; gap=hour+m;//停车应收费的时间(单位: 小时) returngap; } voidpassOut()//便道离开 { try { if(flag==0)throwerroEmp(); intfee=0; system("cls"); printStar(); cout<<"\t\t\t\t您进入了便道离开界面"< cout< " < cout<<"\t\t\t将要离开车的信息为: "< cout<<"\t车牌: 便道"<num <<"号\t\t停车时间: "; fee=feep(&a[front]->timep)*0; cout<<"\t该车应缴纳停车费为: "< <<"元(便车道停车免费)"< a[front]->carNum=0; front=(front+1)%PASS; flag--; cout< ! 汽车离开成功,按任意键返回! ! "< system("pause"); } catch(erroEmp&err) { err.ex(); } } voidpotOut()//停车场离开 { try { if(top==0)throwerroEmp(); intfee=0; top--; system("cls"); printStar(); cout<<"\t\t\t\t您进入了停车场离开界面"< cout< " < cout<<"\t\t\t将要离开车的信息为: "< cout<<"\t车牌: "<carNum<<"\t车位: 停车场"<num <<"号\t\t停车时间: "; fee=feep(&b[top]->timep)*8;//计费公式,每小时8元 cout<<"\t该车应缴纳停车费为: "< <<"元(每小时8元,不足一小时按一小时计算)"< b[top]->carNum=0; cout< ! 汽车离开成功,按任意键返回! ! "< system("pause"); } catch(erroEmp&err) { err.ex(); } } voiddepart()//汽车离开 { intchoice=-1; if(top==0&&flag==0)throwerroEmp(); for(;;) { system("cls"); system("color3a"); printStar(); cout<<"\t\t\t\t欢迎下次光临停车场"< printLine(); cout<<"\t\t\t|1.停车场离开\t\t\t|"< printLine(); cout<<"\t\t\t|2.便道离开\t\t\t|"< printLine(); cout<<"\t\t\t|3.返回\t\t\t|"< printLine(); printStar(); cout<<"\t\t请输入你的选项: "; cin>>choice; switch(choice) { case1: potOut();break; case2: passOut();break; case3: break; default: system("color3c");cout< "< _sleep(1000);break; } if(choice==3)break; } return; } voidsearchNum()//查询车牌 { intnumCar,i=0,flag=1; cout<<"\t\t\t请输入车牌: "; cin>>numCar; for(;i { if(a[i]->carNum==numCar){ cout< flag=0; } } if(flag)for(i=0;i { if(b[i]->carNum==numCar){ cout< flag=0; } } if(flag)cout< "< system("pause"); } voidsearchPot() { intpotCar,nn; cout<<"\t\t操作说明: 按照停车类型加位置来输入所要查找的车位信息\n\t\t如: 停车场10号位,即输入110。 停车场三号位,103。 便道场5号位,205"< cout<<"\t\t请输入需要操作的序数: "; cin>>potCar; if((potCar<121&&potCar>100)||(potCar<221&&potCar>200)){ if(potCar/100==1){ nn=potCar%100-1;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 停车场 管理 系统 程序 设计 说明
![提示](https://static.bdocx.com/images/bang_tan.gif)