#include "Manage.h"
#include"bits/stdc++.h"
Parking_Management::Parking_Management()
{
capacity = MAX_CAPACITY;
QS = new Queue_Stack;
QS->Init_Stack(&QS->S1);
QS->Init_Stack(&QS->S2);
QS->Init_Stack(&QS->S3);
QS->Init_Queue(&QS->Q1);
for (int i = 0; i < MAX_CAPACITY; i++)
{
Pos_info[i].number = i + 1;
Pos_info1[i].number = i + 1;
path[i].number = i + 1;
}
}
void Parking_Management::Enter_Parking()
{
string license_n;
cout << "请输入您的车牌号:";
cin >> license_n;
if ((QS->Full_Stack(&QS->S1))&&(QS->Full_Stack(&QS->S3)))
{
if (QS->Length_Queue(&QS->Q1) != MAX_CAPACITY)
{
QS->EnQueue(&QS->Q1, license_n);
int t = QS->Length_Queue(&QS->Q1);
path[t - 1].license_number = license_n;
path[t - 1].condition = "正在占用";
cout << "\n停车位已满,去便道磕会儿瓜子吧(*^_^*)\n";
}
else
{
cout << "\n便道也满了ヾ(@⌒ー⌒@)ノ" << endl;
return;
}
}
else if(!QS->Full_Stack(&QS->S1))
{
QS->Push_Stack(&QS->S1, license_n);
int t = QS->Length_Stack(&QS->S1);
Pos_info[t - 1].license_number = license_n;
Pos_info[t - 1].condition = "正在使用";
}
else if(QS->Full_Stack(&QS->S1)&&(!QS->Full_Stack(&QS->S3)))
{
QS->Push_Stack(&QS->S3, license_n);
int t = QS->Length_Stack(&QS->S3);
Pos_info1[t - 1].license_number = license_n;
Pos_info1[t - 1].condition = "正在使用";
}
}
void Parking_Management::Exit_Parking()
{
int sign = 0, flag = 0;
int tt;
Print();
string ss1, p;
if ((!(QS->EmptyStack(&QS->S1)))||(!(QS->EmptyStack(&QS->S3))))
{
cout << "\n请输入停车场要离开的车牌号:";
cin >> ss1;
}
else
{
cout << "\n停车场为空\n\n";
return;
}
while (!QS->EmptyStack(&QS->S1))
{
p = QS->Gethead_Stack(&QS->S1);
if (p == ss1)
{
if (!QS->Empty_Queue(&QS->Q1))
{
sign = 1;
for (int i = 0; i < MAX_CAPACITY; i++)
{
if (p == Pos_info[i].license_number)
{
cout << endl;
p = QS->Gethead_Queue(&QS->Q1);
Pos_info[i].license_number = p;
QS->Pop_Queue(&QS->Q1);
tt = i;
for (int i = 0; i < MAX_CAPACITY - 1; i++)
{
path[i].condition = path[i + 1].condition;
path[i].license_number = path[i + 1].license_number;
}
path[MAX_CAPACITY - 1].license_number = "NULL";
path[MAX_CAPACITY - 1].condition = "未使用";
break;
}
}
}
else
{
int i;
for (i = 0; i < MAX_CAPACITY; i++) {
if (p == Pos_info1[i].license_number) {
Pos_info1[i].license_number = "NULL";
Pos_info1[i].condition = "未使用";
break;
}
}
}
}
if (p != ss1)
{
string h = p;
QS->Push_Stack(&QS->S2, h);
}
QS->Pop_Stack(&QS->S1);
}
while (!QS->EmptyStack(&QS->S2))
{
string p = QS->Gethead_Stack(&QS->S2);
QS->Push_Stack(&QS->S1, p);
QS->Pop_Stack(&QS->S2);
}
while (!QS->EmptyStack(&QS->S3))
{
p = QS->Gethead_Stack(&QS->S3);
if (p == ss1)
{
if (!QS->Empty_Queue(&QS->Q1))
{
sign = 1;
for (int i = 0; i < MAX_CAPACITY; i++)
{
if (p == Pos_info1[i].license_number)
{
cout << endl;
p = QS->Gethead_Queue(&QS->Q1);
Pos_info1[i].license_number = p;
QS->Pop_Queue(&QS->Q1);
tt = i;
for (int i = 0; i < MAX_CAPACITY - 1; i++)
{
path[i].condition = path[i + 1].condition;
path[i].license_number = path[i + 1].license_number;
}
path[MAX_CAPACITY - 1].license_number = "NULL";
path[MAX_CAPACITY - 1].condition = "未使用";
break;
}
}
}
else
{
int i;
for (i = 0; i < MAX_CAPACITY; i++) {
if (p == Pos_info1[i].license_number) {
Pos_info1[i].license_number = "NULL";
Pos_info1[i].condition = "未使用";
break;
}
}
}
}
if (p != ss1)
{
string h = p;
QS->Push_Stack(&QS->S2, h);
}
QS->Pop_Stack(&QS->S3);
}
while (!QS->EmptyStack(&QS->S2))
{
string p = QS->Gethead_Stack(&QS->S2);
QS->Push_Stack(&QS->S3, p);
QS->Pop_Stack(&QS->S2);
}
}
void Parking_Management::Print()
{
cout << "\n停车场基本信息:共10个车位" << endl << endl;
if (QS->EmptyStack(&QS->S1)&&QS->EmptyStack(&QS->S3))
{
cout << "当前停车场为空\n\n" << endl;
return;
}
QS->Show_Stack(&QS->S1);
QS->Show_Stack1(&QS->S3);
cout << " \n便道基本信息:\n\n";
QS->Show_Queue(&QS->Q1);
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
这是一个基于C/C++的停车场管理系统,主要包括 Enter_Parking()、Exit_Parking()、Print() 以及一些栈和队列的操作函数。系统通过栈和队列来管理停车场和便道上的车辆,实现了车辆的进场、出场和打印停车信息的功能。 在进场函数 Enter_Parking() 中,系统检查停车场和便道的状态,将车辆加入到合适的位置,并更新车辆的状态信息。如果停车场已满则将车辆加入到便道上。在出场函数 Exit_Parking() 中,系统根据车牌号查找车辆并更新状态信息,实现车辆的出场操作。Print() 函数用于打印停车场和便道的基本信息。 栈 SeqStack 和队列 LQ 是基础的数据结构,用于存储车辆的信息和管理车辆的进出。这个停车场管理系统通过栈和队列的数据结构实现了对车辆的管理,可以较为灵活地处理车辆的进出和信息展示。 停车场分为左右两侧共10个车位,这两侧分别用两个栈来表示,如果这10个车位全停满,后来的汽车进入便道等待,如果停车场内有车离开,便道上的第一辆车进入该车位。
资源推荐
资源详情
资源评论
收起资源包目录
停车场管理系统.rar (12个子文件)
停车场管理系统
Parking
Manage.cpp 5KB
Manage.o 21KB
Parking.layout 357B
Manage.h 978B
Operate.o 9KB
main.cpp 1015B
Operate.cpp 3KB
Makefile.win 1KB
main.o 8KB
Parking.dev 1KB
Operate.h 1KB
Parking.exe 1.93MB
共 12 条
- 1
资源评论
Simon学Java
- 粉丝: 214
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功