设为首页 加入收藏

TOP

C++实现停车场管理系统(二)
2016-12-28 08:16:14 】 浏览:399
Tags:实现 停车场 管理系统
NULL;
CarBase->top--;
}


p = CarBase->CarStack[CarBase->top];
CarBase->CarStack[CarBase->top] = NULL;
CarBase->top--;


while (QuitTemp->top >= 1) //当暂时存储汽车的栈结构中有汽车时汽车重新进站
{
CarBase->top++;
CarBase->CarStack[CarBase->top] = QuitTemp->CarStack[QuitTemp->top];
QuitTemp->CarStack[QuitTemp->top] = NULL;
QuitTemp->top--;
}


ShowLeaveInfo(p, item);


if ((WaitQueue->head != WaitQueue->rear) && CarBase->top {
CTime start_time = CTime::GetCurrentTime(); //获取系统当前时间作为车辆进站时间
q = WaitQueue->head->next;
t = q->data;
CarBase->top++;
cout << "\n便道的" << t->num << "号车进入车场第" << CarBase->top << "号车位.";
t->reach.year = start_time.GetYear();
t->reach.month = start_time.GetMonth();
t->reach.day = start_time.GetDay();
t->reach.hour = start_time.GetHour();
t->reach.min = start_time.GetMinute();


WaitQueue->head->next = q->next;
if (q == WaitQueue->rear)
WaitQueue->rear = WaitQueue->head;
CarBase->CarStack[CarBase->top] = t;
free(q);
}
else cout << "便道里没有车..." << endl;
}
else cout << "挺车场里没有车..." << endl;
}


void CarSystem::ShowLeaveInfo(CarNode *p, int room) //汽车离站时缴费显示
{
CTime end_time = CTime::GetCurrentTime();
p->leave.year = end_time.GetYear();
p->leave.month = end_time.GetMonth();
p->leave.day = end_time.GetDay();
p->leave.hour = end_time.GetHour();
p->leave.min = end_time.GetMinute();
printf("\n离开车辆的车牌号为:");
cout << p->num;
cout << "\n到达时间为: " << p->reach.year << " 年 " << p->reach.month << " 月 " << p->reach.day << " 日 " << p->reach.hour << " 时 " << p->reach.min << " 分";
cout << "\n离开时间为: " << p->leave.year << " 年 " << p->leave.month << " 月 " << p->leave.day << " 日 " << p->leave.hour << " 时 " << p->leave.min << " 分";
cout << "\n应交费用为: " << ((p->leave.hour - p->reach.hour) * 60 + (p->leave.min - p->reach.min)) * 100 << " 元";
free(p);
}


void CarSystem::QueueCarLeave(char a[]) //便道中的车直接离开
{
QCarNode *p,*q;
p = WaitQueue->head->next;
q = WaitQueue->head;
if (WaitQueue->head != WaitQueue->rear)
{
while (strcmp(p->data->num, a) && p != NULL)
{
q = p;
p = p->next;
}
q->next = p->next;
free(p);
}
else
{
cout << "便道中无车!" << endl;
}
}


void CarSystem::ShowInfo() //查询车位状态
{
int choice = 0;
cout << "请输入查看列表:" << endl;
cout << "--- 1.停车场车位状况 ---" << endl;
cout << "--- 2.便道停车位状况 ---" << endl;
cout << "--- 3.返回主菜单 ---" << endl;
while (choice!=3)
{
while (1)
{
cin >> choice;
if (choice >= 1 || choice <= 3) break;
else cout << "请检查输入!" << endl;
}
switch (choice)
{
case 1:
Carstack();
break;
case 2:
Carqueue();
break;
case 3:
return;
break;
default:
break;
}
}
}


void CarSystem::Carstack() //车场车位显示
{
int i;
if (CarBase->top>0)
{
cout << "停车场车位状态:";
cout << "\n车位号\t" << " 到达时间 \t" << "车牌号\n";
for (i = 1; i <= CarBase->top; i++)
{
cout << " " << i << "\t ";
cout << CarBase->CarStack[i]->reach.year << "年" << CarBase->CarStack[i]->reach.month << "月" << CarBase->CarStack[i]->reach.day
<< "日" << CarBase->CarStack[i]->reach.hour << "时" << CarBase->CarStack[i]->reach.min << "分";
cout << "\t " << CarBase->CarStack[i]->num << endl;
}
}
else cout << "\n车场里没有车";
}


void CarSystem::Carqueue() //便道车位显示
{
QCarNode *p;
p = WaitQueue->head->next;
cout << "便道车位状况:" << endl;
if (WaitQueue->head != WaitQueue->rear)
{
cout << "-->-->-->-->-->-->-->-->-->-->-->-->-->-->" << endl;
while (p != NULL)
{
cout << p->data->num << "\t";
p = p->next;
}
cout << endl;
cout << "-->-->-->-->-->-->-->-->-->-->-->-->-->-->" << endl;
}
else
{
cout << "-->-->-->-->-->-->-->-->-->-->-->-->-->-->" << endl;
cout << "便道中无车!" << endl;
cout << "-->-->-->-->-->-->-->-->-->-->-->-->-->-->" << endl;
}
}


2.源文件


#include "CarSystem.h"
#include


using namespace std;
int main()
{
CarSystem CAR; //停车场类
int x = 100;
char a[10];
while (x != 0)
{
system("pause");
system("cls"); //清屏
ShowMenu();
cin >> x;
switch (x)
{
case 0:
exit(0);
break;
case 1:
CAR.Arrival();
cout << endl << "-----------------------------------------" << endl;
cout << "停车场更新..." << endl;
CAR.Carstack();
cout << "-----------------------------------------" << endl;
break;

首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C++实现学生信息管理系统 下一篇C++实现约瑟夫环

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目