立体化停车场设计书1.1 课题任务设停车场有地下和地面两层,统一管理。
地下停车场采用单入口和单出口。
地上停车场采用南北方向的双口,每个口都有一个入口和出口。
停车顺序先地面,后地下。
地面入口处各有一个单车道的等候通道,并允许等候的车辆因急事从等候通道直接开走。
具体的设计任务如下:(1)采用栈、队列和有序表等数据结构。
(2)等候车辆的管理。
(3)地下、地上停车位的管理。
(4)停车计费功能。
1.2 课题原理针对本次课程设计的具体要求,我们设计了如下方案:停车场部选择栈作为基本数据结构,充分利用栈后进先出的数据结构特点,停车场外部的等候区域,针对其“先到先出”的工作特点,选择队列作为基本数据结构。
同时设计了计时计费功能,会员制度,针对不同型号,是否为会员的车辆进行分类收费。
2 需求分析2.1 课题调研为了完成本次课程设计任务,我们对校园周边的停车场运作状况进行了一系列的前期调研,包括停车场的管理系统的运行原理,收费标准等等,为本次课程设计任务的完成打下了良好的基础。
2.2 功能需求此次设计任务,要求停车场分为上下两层,上层为南北双向入口和出口,下层为单向入口出口,并要求我们设计等待区域。
对于收费标准,我们将不同型号的车分类收费,同时增加会员管理制度,对于多次在本停车场停车的会员给予优惠。
3 方案设计3.1 总体功能设计本次课程设计共分为四个主要功能:(1)进入停车场(2)离开停车场(3)查看停车场现状(4)计费功能针对进入停车场的功能,我们设计了“先地上,后地下”,的停放顺序,当地上南北双向任一停车场停满后,再向该停车场进车,会显示“停车场已满”等提示信息,并将车辆停入有剩余车位的其他停车场。
当所有停车场均无停车位时,到来车辆将会进入等待区域,一旦有车辆离开停车场,最先到达等待的区域的车辆将会进入停车场。
针对离开停车场的功能,可选择任一停车场出车,并会根据停车时长,车辆类型,以及是否为会员等信息给出本次停车的费用。
针对查看停车场现状的功能,将显示车牌号,何处停车等相关信息。
此外,我们还设计了计费功能,利用windows系统自带函数获取时间,免去了人工手动输入时间的繁琐步骤,同时,针对不同车型,是否享受会员优惠等差异制定了不同的收费标准,使停车场的运行更为规化,合理化。
3.2 数据结构设计本次课程设计主要使用了栈和队列两种数据结构,具体的设计方案和操作过程将在个人报告中给出,在此不再赘述。
3.3 函数原型设计int main(){system("color E1");cout<<endl;cout<<~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~ "<<endl;cout<<" <<<<<<< 进入停车场管理系统 >>>>>>> "<<endl;cout<<” ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^ "<<endl;cout<<endl;cout<<"^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^"<<endl;cout<<endl;cout<<endl;cout<<endl;Car w;int t = 1;s1.sInitStack();s2.sInitStack();temt1.sInitStack();s3.InitStack(&s3);temp1.InitStack(&temp1);shortcut.InitQueue();while (t){cout<<" ================================================ "<<endl;cout<<" **** ◇1.进入停车场**** "<<endl;cout<<" **** ◇2.离开停车场 **** "<<endl;cout<<" **** ◇3.查看停车场现状**** "<<endl;cout<<" **** ◇0.退出**** "<<endl;cout<<" ================================================ "<<endl;cout<<endl;cout<<"★★★★★★★★请输入功能选项: ";cin>>t;switch (t){case 1: CarIn(&s3,&s1,&s2, &shortcut); break;case 2: CarOut(&s3,&temp1,&s1,&s2,&temt1 ,&shortcut); break;case 3: LookNow(&s3, &temp1, &s1, &s2, &temt1, &shortcut,&w); break;case 0: break;}}return 0;}3.4 用户界面设计运行时为DOS界面,通过增加字符画,更换背景颜色等方法增加界面的美观度。
4 方案实现4.1 开发环境与工具开发环境:VisualC++6.04.2 个人设计实现(按组员分小节)4.2.1 奕设计实现队列类的实现:typedef struct QueueNode //队列结构{Car data;struct QueueNode *next;}QueueNode;class Queue //定义队列类{public:QueueNode *front, *rear;Queue(){cout<<"构造函数"<<endl;};~Queue();int InitQueue();int DestroyQueue(Queue *Q);int EnterQueue(Queue *Q, Car c);int EmptyQueue(Queue*Q);int DeleteQueue(Queue *Q,Car *c);int QueueLength(Queue *Q);};Queue::~Queue(){cout<<"析构函数"<<endl;}int Queue::EmptyQueue(Queue *Q){if (front==rear){cout<<"队列为空"<<endl;return (TRUE);}elsecout<<"队列不为空"<<endl;return (FALSE);}int Queue::InitQueue(){//构造一个空队列front = (QueueNode *)malloc(sizeof(QueueNode)); if (front == NULL){return (FALSE);}else{rear = front;front->next = NULL;cout<<"构造了一个空队列"<<endl;return (TRUE);}}int Queue::DestroyQueue(Queue *Q){//销毁一个队列while (front){rear=front->next;free(front);front=rear;}cout<<"销毁队列成功"<<endl;return 1;}int Queue::EnterQueue(Queue*Q, Car c){rear->next = (QueueNode *)malloc(sizeof(QueueNode)); if (rear->next == NULL){cout<<"车辆入队失败"<<endl;return (FALSE);}else{rear = rear->next;rear->data = c;//rear->data.licence= rear->data.leaved;cout<<"车辆入队成功"<<count<<endl;rear->next = NULL;count++;return (TRUE);}}int Queue::DeleteQueue(Queue *Q,Car *c){//删除队列元素QueueNode *t;if (EmptyQueue( Q)){cout<<"要查找车辆不存在!"<<endl;return (FALSE);}else{t = front->next;if (rear == t)rear = front;(*c)= t->data;front->next = t->next;free(t);cout<<"车辆删除成功"<<endl;count--;return (TRUE);}}int Queue::QueueLength(Queue *Q){if (front!=rear){cout<<"此时队列长队为"<<count-1<<endl;return 1;}else return 0;}4.2.2 王卓君设计实现Time类:#include <stdio.h>#include <stdlib.h>#include <string.h>#include<iostream>#include <iomanip>#include <windows.h>#include <winbase.h>using namespace std;class Time //时间类{private:SYSTEMTIME LocalTime;int month;int day;int hour;int minuet;int second;public:Time(){GetLocalTime(&LocalTime); //取系统时间}void OutputTime(); //输出时间函数int getmonth() {return LocalTime.wMonth;}int getday() {return LocalTime.wDay;}int gethour() {return LocalTime.wHour;}int getminute() {return LocalTime.wMinute;}int getsecond() {return LocalTime.wSecond;}void save(){month=getmonth();day=getday();hour=gethour();minuet=getminute();second=getsecond();}~Time(){}};void Time::OutputTime() //输出当前系统时间{cout<<"当前时间为:"<<getmonth()<<"月"<<getday()<<"日"<<gethour()<<"时"<<getminute()<<"分"<<getsecond()<<"秒"<<endl;}//主函数void main(){Time t;t.OutputTime();cout<<"现在是"<<t.getmonth()<<"月"<<t.getday()<<"日"<<t.gethour()<<"时"<<t.getminute()<<"分"<<t.getsecond()<<"秒"<<endl;}Guest类:#include <stdio.h>#include <stdlib.h>#include <string.h>#include<iostream>#include <iomanip>#include <windows.h>#include <winbase.h>static int carfre[100]={0};//static int carid=0;using namespace std;class Time //时间类{private:SYSTEMTIME LocalTime;int month;int day;int hour;int minuet;int second;public:Time(){GetLocalTime(&LocalTime); //取系统时间}void OutputTime(); //输出时间函数int getmonth() {return LocalTime.wMonth;}int getday() {return LocalTime.wDay;}int gethour() {return LocalTime.wHour;}int getminute() {return LocalTime.wMinute;}int getsecond() {return LocalTime.wSecond;}void save(){month=getmonth();day=getday();hour=gethour();minuet=getminute();second=getsecond();}~Time(){}};void Time::OutputTime() //输出当前系统时间{cout<<"当前时间为:"<<getmonth()<<"月"<<getday()<<"日"<<gethour()<<"时"<<getminute()<<"分"<<endl;#define MAXSIZE 100 //链表的最大长度typedef struct{ //线性表的静态单链表的存储结构//char data[10];int data;int cur;}component,SLinkList[MAXSIZE];typedef struct Car{int leaved;char licence[LICENCESIZE];Time arrive;Time leave;}Car;class Guest:public Time //客户类,继承Time类{public:Time t1,t2;SLinkList carid; //该数组存车牌号//char e[10];int e;int j,k,v;int cartype; //车辆类型:1客车 2货车 3轿车 4越野车 5跑车float price;public:Guest(){for(int i=1,m=0;i<=100,m<100;i++,m++){carid[m].cur=i;//carid[i].data = "0000000";}//j=0;}~Guest(){}int LocateElem(SLinkList carid,int *e); //线性表定位函数,查找值为e的元素void saveid(Car *c,int v); //该函数储存会员的车牌号和停车次数float fee(Time t1,Time t2); //计算价格函float cutprice(float price,int v); //计算打折价格函数};int Guest::LocateElem(SLinkList carid,int *e) //在静态单链线性表中查找第1个值为i的元素若找到,则返回它在表中的位序,否则返回下一位{k=0;//while(k&&strcmp(carid[k].data,e)!=0) //在表中顺链查找while(carid[k].data != *e){k=carid[k].cur;if(!carid[k].data){j=k;k=0;return j+1;}}return k+1;}//LocateElemfloat Guest::fee(Time t1,Time t2) //计算普通价格{if(t1.getmonth()!=t2.getmonth())price=(t2.getmonth()-t1.getmonth())*3000;else if(t1.getday()!=t2.getday())price=(t2.getday()-t1.getday())*500;else{price=((t2.gethour()-t1.gethour())*3600+(t2.getsecond()-t1.getsecond())*60+ (t2.getsecond()-t1.getsecond()))*CHARGE;cout<<"您的车是什么类型?1客车 2货车 3轿车 4越野车 5跑车"<<endl;cin>>cartype;switch(cartype) //1客车 2货车 3轿车 4越野车 5跑车{case 1:case 2:price=price*2;break;case 3:price=price;break;case 4:price=price*1.5;break;case 5:price=price*1.2;break;}}return price;}float Guest::cutprice(float price,int v) //计算会员打折后的价格{//int i = LocateElem(carid,*e);//调用线性表定位函数if(carfre[v-1]>=100)price=price*0.55;else if(carfre[v-1]>=50)price=price*0.7;else if(carfre[v-1]>=20)price=price*0.85;elseprice=price*0.95;return price;}//LocateElem函数的测试函数void main(){Guest guest;int e;SLinkList carid;for(int n=0,x=1111;n<5,x<=5555;n++,x=x+1111){carid[n].data=x;}for(int i=1,m=0;i<=100,m<100;i++,m++){carid[m].cur=i;}for(int y=5;y<100;y++){carid[y].data=0;}cout<<"请输入要查询的值:";cin>>e;cout<<"结果是存在第"<<guest.LocateElem(carid,&e)<<"位"<<endl;}4.2.3 小玉设计实现void CarOut1(SqStack *parking1,SqStack *parking2,SqStack *temt, Queue *shortcutt) {int a;char licence[LICENCESIZE];Car c;Time t2;t2.save();Guest guest;t2.OutputTime();cout<<"★★★★★★★★请输入车牌号:";gets(licence);printf("★★★★★★★★南停车场出车请输入0,北停车场出车请输入1.\n");scanf("%d%*c", &a);if(!(a==1)){int i = 0;s1.sPop(&s1, &c);while (strcmp(c.licence, licence) != 0 && s1.top!=0){temt1.sPush(&temt1, c);s1.sPop(&s1, &c);i++;}c.leave=t2;int x;float price;cout<<"★★★★★★★★您是否是会员?1是 2否★★★"; cin>>x;if(x==1){price= guest.fee(c.arrive,c.leave);price= guest.cutprice();}elseprice=guest.fee(guest.t1,guest.t2);cout<<"★★★★★★★★该车应付"<<fabs(price)<<"元"<<endl;while (!s1.sEmpty(&s1)){temt1.sPop(&temt1, &c);s1.sPush(&s1, c);}if (!shortcut.EmptyQueue( &shortcut)){shortcut.DeleteQueue(&shortcut,& c);s1.sPush(&s1, c);}c.leave=t2;printf("\n");}else{s2.sPop(&s2,&c);while (strcmp(c.licence, licence) != 0){temt1.sPush(&temt1, c);s2.sPop(&s2, &c);}c.leave=t2;int x;float price;cout<<"★★★★★★★★您是否是会员?★1是☆2否★★★";cin>>x;if(x==1){price=guest.fee(c.arrive,c.leave);price=guest.cutprice();}elseprice=guest.fee(guest.t1,guest.t2);cout<<"★★★★★★★★该车应付"<<fabs(price)<<"元"<<endl;while (!temt1.sEmpty(&temt1)){temt1.sPop(&temt1, &c);s2.sPush(&s2, c);}if (!shortcut.EmptyQueue(&shortcut)){shortcut.DeleteQueue(&shortcut,& c);s2.sPush(&s2, c);}printf("\n");}}void CarOut2(Stack *park, Stack *temp,Queue *Q){char licence[LICENCESIZE];Car c;Time t2;t2.save();Guest guest;t2.OutputTime();cout<<"★★★★★★★★请输入车牌号:";gets(licence);s3.Pop(&s3, &c);while (strcmp(c.licence, licence) != 0){temp1.Push(&temp1, c);s3.Pop(&s3, &c);}c.leave=t2;int x;float price;cout<<"★★★★★★★★您是否是会员?★1是☆2否★★★";cin>>x;if(x==1){price=guest.fee(c.arrive,c.leave);price=guest.cutprice();}elseprice=guest.fee(guest.t1,guest.t2);cout<<"★★★★★★★★该车应付"<<fabs(price)<<"元"<<endl;while (!s3.EmptyStack(&temp1)){temp1.Pop(&temp1, &c);s3.Push(&s3, c);}if (!shortcut.EmptyQueue( Q)){shortcut.DeleteQueue(&shortcut, &c);s3.Push(&s3, c);}printf("\n");}void CarOut(Stack *park, Stack *temp,SqStack *parking1,SqStack *parking2,SqStack *temt ,Queue *shortcut){int P;cout<<"★★★★★★★★地上停车场出车请输入★1,地下停车场出车请输入★2☆☆☆";scanf("%d%*c", &P);switch(P){case 1:CarOut1(parking1, parking2,temt, shortcut );break;case 2:CarOut2(park, temp, shortcut);break;}}4.2.4 天舒设计实现typedef struct Car{int licence;}Car;class SqStack{public:Car data[STACKSIZE];int top;int base;SqStack();void InitSqStack(SqStack *s);int EmptySqStack(SqStack *s);int FullSqStack(SqStack *S);int SGetTop(SqStack *s,Car c);int SPush(SqStack *s,Car c);int SPop(SqStack *s,Car *c);};SqStack::SqStack(){}//析构函数int SqStack::EmptySqStack(SqStack *s){if (base==top){cout<<"地上停车场现无车,栈为空!"<<endl; return (TRUE);}else{cout<<"地上停车场现有车,栈不为空!"<<endl;return (FALSE);}}int SqStack::FullSqStack(SqStack *S){if (top == STACKSIZE - 1){cout<<"地上停车场车辆已满,栈满!"<<endl;return (TRUE);}else{cout<<"地上停车场还有空位,栈未满!"<<endl;return (FALSE);}int SqStack::SPush(SqStack *S, Car c){if (FullSqStack(S))return (FALSE);else{top++;data[top] = c;cout<<"车辆已入栈,成功停入地上停车场!"<<endl;return (TRUE);}}int SqStack::SPop(SqStack *S, Car *c){if (EmptySqStack(S))return (FALSE);else{(*c) = data[top];top--;cout<<"车辆已出栈,离开地上停车场,欢迎下次光临!"<<endl; return (TRUE);}}int SqStack::SGetTop(SqStack *s,Car c){if(top==base)return FALSE;elsec=data[top-1];top--;return (TRUE);}//若栈非空,则返回s的栈顶元素;否则返回ERRORvoid SqStack::InitSqStack(SqStack *s){top=0;base=0;cout<<"现构造一个空栈!"<<endl;}//置栈一个空栈Sclass Stackpublic:Car data[STACKSIZE];int top;int base;Stack();void InitStack(Stack *s);int EmptyStack(Stack *s);int FullStack(Stack *S);int GetTop(Stack *s,Car c);int Push(Stack *s,Car c);int Pop(Stack *s,Car *c);};Stack::Stack(){cout<<"现已构造一个栈类"<<endl;}//析构函数int Stack::EmptyStack(Stack *S){if (base==top){cout<<"地下停车场现无车,栈为空!"<<endl; return (TRUE);}else{cout<<"地下停车场现有车,栈不为空!"<<endl;return (FALSE);}}int Stack::FullStack(Stack *S){if (top == STACKSIZE - 1){cout<<"地下停车场车辆已满,栈满!"<<endl;return (TRUE);}else{cout<<"地下停车场还有空位,栈未满!"<<endl;return (FALSE);}}int Stack::Push(Stack *S, Car c){if (FullStack(S))return (FALSE);else{top++;data[top] = c;cout<<"车辆已入栈,成功停入地下停车场!"<<endl;return (TRUE);}}int Stack::Pop(Stack *S, Car *c){if (EmptyStack(S))return (FALSE);else{(*c) = data[top];top--;cout<<"车辆已出栈,离开地下停车场,欢迎下次光临!"<<endl;return (TRUE);}}int Stack::GetTop(Stack *s,Car c){if(top==base)return FALSE;elsec=data[top-1];top--;return (TRUE);}//若栈非空,则返回s的栈顶元素;否则返回ERRORvoid Stack::InitStack(Stack *s){top=0;base=0;cout<<"现构造一个空栈!"<<endl;}//置栈一个空栈S4.2.5 嘉文设计实现void CarIn(Stack *park, SqStack *parking1,SqStack *parking2,Queue *shortcuttt)int q=1;Car c;Time t1;Guest guest;t1.OutputTime();t1.save();c.arrive=t1;cout<<endl;guest.saveid(&c);if((s3.FullStack(&s3)==1)&&(s1.sFullStack(&s1)==1)&&(s2.sFullStack(&s2)==1)){cout<<"★★★★★★★★停车场已满,新来的车在过道等待!"<<endl;shortcut.EnterQueue( &shortcut, c);}else{if((s1.sFullStack(&s1)==1)&&(s2.sFullStack(&s2)==1)){cout<<"★★★★★★★★地上停车场已满,请停入地下停车场"<<endl;cout<<"★★★★★★★★车已在停车场停车,现在开始计时☆☆☆";cout<<endl;s3.Push(&s3, c);system("pause");}else{if((s1.sFullStack(&s1)==0)&&(s2.sFullStack(&s2)==0)){cout<<"★★★★★★★★南北停车场均有车位★★★★★★★★"<<endl;cout<<endl;cout<<"★★★★★★★★请选择车辆进口编号,★南:1,☆北:2"<<endl;cout<<"★★★★★★★★请输入入口方向:";scanf("%d%*c", &q);switch(q){case 1:s1.sPush(&s1,c);break;case 2:s2.sPush(&s2, c);break;}}else if((s1.sFullStack(& s1)==0)&&(s2.sFullStack(& s2)==1)){cout<<"★★★★★★★★北入口已满,车辆进入南入口"<<endl;s1.sPush(&s1,c);system("pause");}else if((s1.sFullStack(parking1)==1)&&(s2.sFullStack(parking2)==0)){cout<<"★★★★★★★★南入口已满,车辆进入北入口"<<endl;s2.sPush(&s2, c);system("pause");}}cout<<"★★★★★★★★车已在停车场停车,现在开始计时!"<<endl;cout<<"★★★★★★★★请按任意键继续操作!★★★★★★★★";getchar();system("cls");system("color b0");}printf("\n");}void LookNow(Stack *park, Stack *temp,SqStack *parking1,SqStack *parking2,SqStack *temt,Queue *shortcut,Car *c){QueueNode *p;while (!s1.sEmpty(&s1)){s1.sPop(&s1,c);temt1.sPush(&temt1,* c);}while (!temt1.sEmpty(&temt1)){temt1.sPop(&temt1, c);cout<<"★★★★★★★★车辆停车信息 "<<c->licence<<":地上南停车场停车★★★★"<<endl;s1.sPush(&s1,* c);}while (!s2.sEmpty(&s2)){s2.sPop(&temt1, c);temt1.sPush(&temt1, *c);}while (!temt1.sEmpty(&temt1)){temt1.sPop(&temt1, c);cout<<"★★★★★★★★车辆停车信息 "<<c->licence<<":地上北停车场停车★★★★"<<endl;s2.sPush(&s2, *c);}while (!s3.EmptyStack(&s3)){s3.Pop(&s3, c);temp1.Push(&temp1, *c);}while (!temp1.EmptyStack(&temp1)){temp1.Pop(&temp1, c);cout<<"★★★★★★★★车辆停车信息 "<<c->licence<<":地下停车场停车★★★★"<<endl;s3.Push(&s3, *c);}p = shortcut->front->next;while (p != NULL){cout<<"★★★★★★★★车辆停车信息"<<c->licence<<":排队等待中..."<<endl;p = p->next;}printf("\n");}int main(){system("color E1");cout<<endl;cout<<"~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~ "<<endl;cout<<" <<<<<<< 进入停车场管理系统 >>>>>>> "<<endl;cout<<^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^ "<<endl;cout<<endl;cout<<"~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^"<<end l;cout<<endl;cout<<endl;cout<<endl;Car w;int t = 1;s1.sInitStack();s2.sInitStack();temt1.sInitStack();s3.InitStack(&s3);temp1.InitStack(&temp1);shortcut.InitQueue();while (t){cout<<" ================================================ "<<endl;cout<<" **** ◇1.进入停车场**** "<<endl;cout<<" **** ◇2.离开停车场 **** "<<endl;cout<<" **** ◇3.查看停车场现状**** "<<endl;cout<<" **** ◇0.退出**** "<<endl;cout<<" ================================================ "<<endl;cout<<endl;cout<<"★★★★★★★★请输入功能选项: ";cin>>t;switch (t){case 1: CarIn(&s3,&s1,&s2, &shortcut); break;case 2: CarOut(&s3,&temp1,&s1,&s2,&temt1 ,&shortcut); break;case 3: LookNow(&s3, &temp1, &s1, &s2, &temt1, &shortcut,&w); break;case 0: break;}}return 0;}5 测试与调试5.1 个人测试(按组员分小节)5.1.1 奕测试#include <stdio.h>#include <stdlib.h>#include <string.h>#include<iostream>#include <iomanip>#include <windows.h>#include <winbase.h>#include <math.h>#define STACKSIZE 3 //设置地下停车场容量#define LICENCESIZE 10//设置车牌号static int count=1;#define TRUE 1#define FALSE 0using namespace std;typedef struct Car{int leaved;char licence[LICENCESIZE];}Car;typedef struct QueueNode //队列结构{Car data;struct QueueNode *next;}QueueNode;class Queue //定义队列类{public:QueueNode *front, *rear;Queue(){cout<<"构造函数"<<endl;};~Queue();int InitQueue();int DestroyQueue(Queue *Q);int EnterQueue(Queue *Q, Car c);int EmptyQueue(Queue*Q);int DeleteQueue(Queue *Q,Car *c);int QueueLength(Queue *Q);};Queue::~Queue(){cout<<"析构函数"<<endl;} int Queue::EmptyQueue(Queue *Q){if (front==rear){cout<<"队列为空"<<endl;return (TRUE);}elsecout<<"队列不为空"<<endl;return (FALSE);}int Queue::InitQueue(){//构造一个空队列front = (QueueNode *)malloc(sizeof(QueueNode));if (front == NULL){return (FALSE);}else{rear = front;front->next = NULL;cout<<"构造了一个空队列"<<endl;return (TRUE);}}int Queue::DestroyQueue(Queue *Q){//销毁一个队列while (front){rear=front->next;free(front);front=rear;}cout<<"销毁队列成功"<<endl;return 1;}int Queue::EnterQueue(Queue*Q, Car c){rear->next = (QueueNode *)malloc(sizeof(QueueNode)); if (rear->next == NULL){cout<<"车辆入队失败"<<endl;return (FALSE);}else{rear = rear->next;rear->data = c;//rear->data.licence= rear->data.leaved; cout<<"车辆入队成功"<<count<<endl;rear->next = NULL;count++;return (TRUE);}}int Queue::DeleteQueue(Queue *Q,Car *c){//删除队列元素QueueNode *t;if (EmptyQueue( Q)){cout<<"要查找车辆不存在!"<<endl;return (FALSE);}else{t = front->next;if (rear == t)rear = front;(*c)= t->data;front->next = t->next;free(t);cout<<"车辆删除成功"<<endl;count--;return (TRUE);}}int Queue::QueueLength(Queue *Q){if (front!=rear){cout<<"此时队列长队为"<<count-1<<endl;return 1;}else return 0;}int main(){Car c;Car c1;Car c2;Queue::Queue();q.InitQueue();q.EnterQueue (&q, c);q.EnterQueue(&q,c1);q.EnterQueue(&q,c2);q.QueueLength(&q);q.DeleteQueue(&q,&c);q.QueueLength(&q);q.EmptyQueue(&q);q.DestroyQueue(&q);cout<<"程序测试结束,按任意键结束!"<<endl; return 0;}5.1.2 王卓君测试获取系统时间功能测试:void main(){t.OutputTime();cout<<"现在是"<<t.getmonth()<<"月"<<t.getday()<<"日"<<t.gethour()<<"时"<<t.getminute()<<"分"<<t.getsecond()<<"秒"<<endl;}LocateElem函数的测试函数void main(){Guest guest;int e;SLinkList carid;for(int n=0,x=1111;n<5,x<=5555;n++,x=x+1111){carid[n].data=x;}for(int i=1,m=0;i<=100,m<100;i++,m++){carid[m].cur=i;}for(int y=5;y<100;y++){carid[y].data=0;}cout<<"请输入要查询的值:";cin>>e;cout<<"结果是存在第"<<guest.LocateElem(carid,&e)<<"位"<<endl; }saveid函数的测试函数void main(){Guest guest;Car car;SLinkList carid;for(int n=0,x=1111;n<5,x<=5555;n++,x=x+1111){carid[n].data=x;}for(int i=1,m=0;i<=100,m<100;i++,m++){carid[m].cur=i;}for(int y=5;y<100;y++){carid[y].data=0;}for(int w=0;w<5;w++){carfre[w]=35;}int v,id;cout<<"请输入车牌号:"<<endl;cin>>id;v=guest.LocateElem(carid,&id);guest.saveid(&car,v);}price函数的测试函数void main(){Time t1;t1.save();//t2.save();Guest guest;SLinkList carid;for(int n=0,x=1111;n<5,x<=5555;n++,x=x+1111) {carid[n].data=x;}for(int i=1,m=0;i<=100,m<100;i++,m++){carid[m].cur=i;}for(int y=5;y<100;y++){carid[y].data=0;}for(int w=0;w<5;w++){carfre[w]=35;}float pri;int id,v;cout<<"请输入车牌号:"<<endl;cin>>id;v=guest.LocateElem(carid,&id);cout<<"价格测试:"<<endl;Time t2;t2.save();pri=guest.fee(t1,t2);pri=guest.cutprice(pri,v);cout<<"应收费"<<pri<<"元"<<endl;}5.1.3 天舒测试测试函数如下:void main(){ int n;cout<<"欢迎进入停车场栈测试~ 请选择停车地点地上停车场:1;地下停车场:2;"<<endl;cin>>n;if(n=1){Car c1;SqStack s1;cout<<"欢迎进入地上停车场栈测试~"<<endl;system("pause");s1.InitSqStack(&s1);s1.EmptySqStack( &s1);s1.FullSqStack(&s1);printf("请输入车辆车牌号:");cin>>c1.licence;s1.SPush(&s1,c1);cout<<"成功入栈车辆车牌号为:"<<c1.licence<<endl;s1.SPop(&s1, &c1);}else{Car c;Stack s3;cout<<"欢迎进入地下停车场栈测试~"<<endl;system("pause");s3.InitStack(&s3);s3.EmptyStack( &s3);s3.FullStack(&s3);printf("请输入车辆车牌号:");cin>>c.licence;s3.Push(&s3,c);cout<<"成功入栈车辆车牌号为:"<<c.licence<<endl;s3.Pop(&s3, &c);system("pause");}}5.1.4 小玉测试5.1.5 嘉文测试小玉,嘉文设计部分的测试将在系统运行中给出,在此不再赘述。