1、1停车场管理2程序文件n源文件(.cpp文件)main.cppn头文件(.h文件)lk_stack.hlk_list.hnode.hutility.hvehiclestop.h3文件视图4main.cpp文件int main(void)int maxnum,rate;char ch;coutmaxnumrate;StoppingPlace myStoppingPlace(maxnum,rate);VehicleType veArrive,veLeave;while(ch!=4)coutendl1.车辆到达;coutendl2.车辆离开;coutendl3.显示状态;coutendl4.结束;c
2、outendlch;5main.cpp文件switch(ch)case1:coutveArrive.numveArrive.time;myStoppingPlace.Arrive(veArrive);break;case2:coutveLeave.numveLeave.time;myStoppingPlace.Leave(veLeave);break;case3:myStoppingPlace.DisplayStatus();break;return 0;6vehiclestop.h文件,包含VehicleType结构体说明和StoppingPlace类声明和接口函数,以及重载的Write函数
3、#include lk_stack.h#include lk_list.hstruct VehicleTypeunsigned int num;unsigned int time;void Write(const struct VehicleType&e)/这里对utility提供的Write函数进行了重载/操作结果:显示数据元素 cout(e.num,e.time);7vehiclestop.h文件,包含VehicleType结构体说明和StoppingPlace类声明和接口函数,以及重载的Write函数class StoppingPlaceprivate:LinkStack*pStopPa
4、th;LinkList*pShortcutPath;int maxNumOfStopVehicle;int rate;bool ExistVehicleInStopPath(const VehicleType&vehicle)const;int LocateInpShortcutPath(const VehicleType&vehicle)const;public:StoppingPlace(int n,int r);/构造函数,这个要自己写virtual StoppingPlace();/这里要增加一对花括号void DisplayStatus()const;void Arrive(const VehicleType&vehicle);void Leave(const VehicleType&vehicle);8StoppingPlace类的构造函数StoppingPlace:StoppingPlace(int n,int r)maxNumOfStopVehicle=n;rate=r;pStopPath=new LinkStack;pShortcutPath=new LinkList;