没有合适的资源?快使用搜索试试~ 我知道了~
停车场管理系统程序设计.docx
需积分: 0 0 下载量 16 浏览量
2023-05-24
11:18:22
上传
评论
收藏 1.02MB DOCX 举报
温馨提示
试读
17页
停车场管理系统程序设计.docx
资源推荐
资源详情
资源评论
成功是失败之母,一切都是努力的结果
一、
二、 停车场管理系统
1.1 设计要求
1.1.1 问题描述
设计一个停车场管理系统,模拟停车场的运作,此程序具有以下功能:
① 汽车到达,则显示汽车在停车场内或便道上的停车位置。
② 若车离去,则显示汽车在停车场内停留的时间和应缴纳的费用(在便道上停留的时间不
收费)。
1.1.2 基本要求
①要求以栈模拟停车场,以队列模拟车场外地便道,按照从终端读入的输入数据序列进行模
拟管理。
② 求处理的数据元素包括三个数据项:汽车“到达”或“离去”信息。汽车牌照号码以及
离去的时刻。
③ 要求栈以顺序结构实现,队列以链表实现。
1.1.3 测试数据
自行设计一组在停车场上停车的数据和便道上停车的数据。
1.1.4 实现提示
该停车场能容纳车辆的数量,便道上的停车数量。车辆到达对应栈的入栈操作,车辆离开对
应栈的出栈操作。
1.2 设计代码及注释
#include<iostream>
#include<time.h>
#include<ctime>
#include<dos.h>
#include<windows.h>
using namespace std;
#define PASS 20
#define POT 20
struct passLot//便道队列数据结构
{
int num;//车位号
time_t timep;//停车时间
int carNum;//停车的车牌号码
页脚内容
1
成功是失败之母,一切都是努力的结果
};
struct potLot//停车场栈数据结构
{
int num;
time_t timep;
int carNum;
};
void printLine()//打印下划线(作为主界面图表的框架)
{
cout<<"\t\t\t___________________________________"<<endl;
return;
}
void printStar()//打印星号
{
cout<<endl<<"\t\t******************************************************"<<endl;
}
class erroFull//停车位满时异常类
{public:
erroFull()
{
system("color 3c");
}
void ex()
{
cout<<endl<<"\t\t\t!!!停车场位已满!"<<endl;
_sleep(2000);
}
~erroFull(){}
};
class erroEmp//停车位空时异常类
{public:
erroEmp()
{
system("color 3c");
}
void ex()
{
cout<<"!!!停车场位为空!"<<endl;
_sleep(2000);
页脚内容
2
成功是失败之母,一切都是努力的结果
}
~erroEmp(){}
};
class parkingLot//停车场类
{
public:
parkingLot()
{
passLot* pa;//便道停车位指针
potLot* po;//停车场停车位指针
flag=0;//用来记忆队列(便道)中停车的数量
rear=front=0;//初始化队列头尾
base=0;
top=base;//初始化栈头尾
int i=0;//初始化停车场和便道空间以及车位号
for(;i<POT;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 停车场数据已清空。"<<endl;
}
void passLG()//便道管理函数
{
try
{
if(flag==20) throw erroFull();//如果停车位已满,则抛出车位慢得异常情况
system("cls");
printStar();
cout<<"\t\t\t\t 您进入了便道停车界面"<<endl;
页脚内容
3
成功是失败之母,一切都是努力的结果
cout<<endl<<"\t\t\t 便 道 停 车 场 共 有 20 个 车位,现 共停"<<flag<<"个车位。
"<<endl<<endl;
cout<<"\t\t\t 请输入将要停车的号码:";
cin>>a[rear]->carNum;
a[rear]->timep=time(NULL);
cout<<endl<<"\t\t\t!!汽车停放在"<<a[rear]->num<<"车位成功,系统将在一秒后返回
上层界面!!"<<endl;
rear=(rear+1)%PASS;
flag++;
_sleep(1000);
}
catch(erroFull &err)
{
err.ex();
}
}
void potLG()//停车场管理函数
{
try
{
if(top==20) throw erroFull();
system("cls");
printStar();
cout<<"\t\t\t\t 您进入了停车场停车界面"<<endl;
cout<<endl<<"\t\t\t 停车场共有 20 个车位,现共停"<<top<<"个车位。"<<endl<<endl;
cout<<"\t\t\t 请输入将要停车的号码:";
cin>>b[top]->carNum;
b[top]->timep=time(NULL);
cout<<endl<<"\t\t\t!!汽车停放在"<<b[top]->num<<"车位成功,系统将在一秒后返回上
层界面!!"<<endl;
top++;
_sleep(1000);
}
catch(erroFull &err)
{
err.ex();
}
}
void arrive()//汽车到达
{
页脚内容
4
剩余16页未读,继续阅读
资源评论
ngz_ztf
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功