




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 #include#include#include#include#includeusing namespace std;#define PASS 20#define POT 20struct passLot/便道队列数据结构int num;/车位号time_t timep;/停车时间int carNum;/停车的车牌号码1;struct potLot/停车场栈数据结构int num;time_t timep;int carNum;void printLine()/打印下划线(作为主界面图表的框架)coutttt_endl;return;void printStar()/打印星号coutend
2、ltt*endl;class erroFull/停车位满时异常类public:erroFull()system(color 3c);void ex()coutendlttt!停车场位已满!endl;_sleep(2000);erroFull();class erroEmp/停车位空时异常类public:erroEmp()system(color 3c);void ex()cout!停车场位为空!endl;_sleep(2000);2erroEmp();class parkingLot/停车场类public:parkingLot()passLot* pa;/便道停车位指针potLot* po;/
3、停车场停车位指针flag=0;/用来记忆队列(便道)中停车的数量rear=front=0;/初始化队列头尾base=0;top=base;/初始化栈头尾int i=0;/初始化停车场和便道空间以及车位号for(;inum=i+1;ai-carNum=0;po=(potLot*)malloc(sizeof(potLot);bi=po;bi-num=i+1;bi-carNum=0;parkingLot()couttt停车场数据已清空。endl;void passLG()/便道管理函数tryif(flag=20) throw erroFull();/如果停车位已满,则抛出车位慢得异常情况system
4、(cls);printStar();couttttt您进入了便道停车界面endl;3coutendlttt 便道停车场共有 20 个车位,现共停flag个车位。endlendl;coutarear-carNum;arear-timep=time(NULL);rear=(rear+1)%PASS;flag+;_sleep(1000);catch(erroFull &err)err.ex();void potLG()/停车场管理函数tryif(top=20) throw erroFull();system(cls);printStar();couttttt您进入了停车场停车界面endl;coute
5、ndlttt停车场共有20个车位,现共停top个车位。endlendl;coutbtop-carNum;btop-timep=time(NULL);top+;_sleep(1000);catch(erroFull &err)err.ex();void arrive()/汽车到达4int choice=-1;if(top=20&flag=20) throw erroFull();for(;)system(cls);printStar();couttttt欢迎进入停车场endlendl;printLine();coutttt|1.停车场停车ttt |endl;/*打印两个空格*/printLine
6、();coutttt|2.便道停车ttt |endl;printLine();coutttt|3.返回printLine();ttt |endl;printStar();coutchoice;switch(choice)case 1:potLG();break;case 2:passLG();break;case 3:break;default:system(color 3c);coutendltttt输入格式不正确!endl;_sleep(1000);break;if(choice=3)break;return;int feep(time_t* tmp)/费用计算int gap=0,m=0,
7、hour=0,min=0,sec=0;/设置数据用来计算时间间隔,停车时、分、秒。local=localtime(tmp);/将存储的时间转化为当地时间日历couttm_hour:tm_min:tm_sectm_hour;/保存停车时刻min=local-tm_min;sec=local-tm_sec;now=time(NULL);nowp=localtime(&now);coutt当前时间为:tm_hour:tm_min:tm_sectm_hour-hour;/求出停车的时间间隔min= nowp-tm_min-min;sec= nowp-tm_sec-sec;if(sec0)min-;se
8、c=60+sec;/进行秒、分钟、秒时间转换if(min0) hour-;min=60+min;coutt汽车共停了 hour小时 min分 sec秒endl;if(0!=min)|(0!=sec) m=1;gap= hour+m;/停车应收费的时间(单位:小时)return gap;void passOut()/便道离开tryif(flag=0) throw erroEmp();int fee=0;system(cls);printStar();couttttt您进入了便道离开界面endl;coutendlttt便道停车场共有20个车位,现共停flag-1个车位。endlendl;coutt
9、tt将要离开车的信息为:endl;coutt车牌号码:carNumt车位:便道numtimep)*0;coutt该车应缴纳停车费为:fee元(便车道停车免费)carNum=0;front=(front+1)%PASS;flag-;system(pause);catch(erroEmp &err)err.ex();void potOut()/停车场离开6tryif(top=0) throw erroEmp();int fee=0;top-;system(cls);printStar();couttttt您进入了停车场离开界面endl;coutendlttt停车场共有20个车位,现共停top个车位
10、。endlendl;coutttt将要离开车的信息为:endl;coutt车牌号码:carNumt车位:停车场numtimep)*8;/计费公式,每小时8元coutt该车应缴纳停车费为:fee元(每小时8元,不足一小时按一小时计算)carNum=0;system(pause);catch(erroEmp &err)err.ex();void depart()/汽车离开int choice=-1;if(top=0&flag=0) throw erroEmp();for(;)system(cls);system(color 3a);printStar();couttttt欢迎下次光临停车场endl
11、endl;printLine();coutttt|1.停车场离开ttt |endl;/*打印两个空格*/printLine();coutttt|2.便道离开ttt |endl;printLine();coutttt|3.返回ttt |endl;7printLine();printStar();coutchoice;switch(choice)case 1:potOut();break;case 2:passOut();break;case 3:break;default:system(color 3c);coutendltttt输入格式不正确!endl;_sleep(1000);break;i
12、f(choice=3)break;return;void searchNum()/查询车牌号码int numCar,i=0,flag=1;coutnumCar;for(;icarNum=numCar) coutendlttt车牌号为numCar的车子停在便车道num位endl;flag=0;if(flag)for(i=0;icarNum=numCar) coutendlttt车牌号为numCar的车子停在停车道num位endl;flag=0;if(flag) coutendl该汽车未停在本停车场!endl;system(pause);void searchPot()int potCar,nn;
13、8couttt如:停车场10号位,即输入110。停车场三号位,103。便道场5号位,205endl;coutpotCar;if(potCar100)|(potCar200)if(potCar/100=1)nn=potCar%100-1;if(bnn-carNum=0) couttt你说查询的车位没有停车endl;else cout停车场nn车位停车的车牌号是:carNumcarNum=0) couttt你说查询的车位没有停车endl;else cout便车道nn车位停车的车牌号是:carNumendl;else couttt您所输入的数字不正确!endl;system(pause);void
14、search()/号码查询int choice=-1;if(top=0&flag=0) throw erroEmp();for(;)system(cls);system(color 3a);printStar();couttttt您进入了号码查询界面endlendl;printLine();coutttt|1.根据车牌号码查询tt |endl;/*打印两个空格*/printLine();coutttt|2.直接查询指定车位tt |endl;printLine();coutttt|3.返回printLine();ttt |endl;printStar();coutchoice;switch(ch
15、oice)case 1:searchNum();break;9case 2:searchPot();break;case 3:break;default:system(color 3c);coutendltttt输入格式不正确!endl;_sleep(1000);break;if(choice=3)break;return;private:int flag,front,rear,top,base;/设置访问栈和队列passLot* aPASS;/以顺序方式存储栈和队列,并且都设为20个车位potLot* bPOT;tm* local,*nowp;time_t now; /设置时间型变量;/停车
16、场类结束void main()/程序运行主函数parkingLot a;int choice=-1;for(;)/使主界面能够自动初始化和重复使用system(cls);system(color 3a);/设为主背景为湖蓝色printStar();couttttt欢迎进入停车场管理系统endlendl;time_t t;/时间结构或者对象t=time(NULL);/获取当前系统的日历时间coutttttttctime(&t); /显示当前时间printLine();coutttt|1.汽车到达ttt |endl;/*打印两个空格*/printLine();coutttt|2.汽车离去ttt |endl;printLine();coutttt|3.汽车牌号查询ttt |endl;printLine();coutttt|4.退出管理系统ttt |endl;printLine();printStar();coutchoice;switch(choice)
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年山东省环保发展集团有限公司校园招聘(144人左右)笔试参考题库附带答案详解
- 2025新员工岗前安全培训考试试题及答案(基础+提升)
- 25年公司主要负责人安全培训考试试题及参考答案(综合卷)
- 25年企业员工安全培训考试试题含答案【A卷】
- 2025简易知识产权专利合同范本
- 2025商品房买卖合同指南
- 2025国际航空运输合同样本
- 2025年硅力敏传感器合作协议书
- 2025网络安全顾问聘用合同书
- 2025建筑公司农民工劳动合同
- 2024年中铁集装箱运输有限责任公司招聘笔试参考题库附带答案详解
- 新生儿肠胀气课件
- 物业管理中英文对照外文翻译文献
- 专题17浮力与液面升降问题(选择、填空题)- 中考物理一轮复习专题练习(解析版)
- 《麻醉后苏醒延迟》课件
- 《物业客服培训》课件
- 06J403-1 楼梯、栏杆、栏板图集
- 实习中遇到的问题
- 供货合同终止申请书范本
- 中国军力报告2023全文
- 深圳市南山区教育系统招聘公办幼儿园园长考试题库2023
评论
0/150
提交评论