当前位置:文档之家› 停车场管理PPT课件

停车场管理PPT课件

8
void Write(const struct VehicleType &e) //这里对utility提供的Write函数进行了重载 // 操作结果: 显示数据元素 {
cout<<"("<<e.num<<","<<e.time<<")";
}
6
vehiclestop.h文件,包含VehicleType结构体说明和 StoppingPlace类声明和接口函数,以及重载的Write函数
class StoppingPlace { private:
LinkStack<VehicleType> *pStopPath; LinkList<VehicleType> *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); };
停车场管理
1
程序文件
源文件(.cpp文件)
main.cpp
头文件(.h文件)
lk_stack.h lk_list.h node.h utility.h vehiclestop.h
2
文件视图
3
main.cpp文件
int main(void) {
int maxnum,rate; char ch; cout<<"输入停车道的最大数与停单位时间的收费值:"; cin>>maxnum>>rate; StoppingPlace myStoppingPlace(maxnum,rate); VehicleType veArrive,veLeave; while(ch!='4') {
cout<<endl<<"1.车辆到达"; cout<<endl<<"2.车辆离开"; cout<<endl<<"3.显示状态"; cout<<endl<<"4.结束"; cout<<endl<<ຫໍສະໝຸດ 请选择功能(1-4):";
cin>>ch;
4
main.cpp文件
switch(ch) { case'1': cout<<"输入车辆编号与到达时间:"; cin>>veArrive.num>>veArrive.time; myStoppingPlace.Arrive(veArrive); break; case'2': cout<<"输入车辆编号与离开时间:"; cin>>veLeave.num>>veLeave.time; myStoppingPlace.Leave(veLeave); break; case'3': myStoppingPlace.DisplayStatus(); break; }
} return 0; }
5
vehiclestop.h文件,包含VehicleType结构体说明和 StoppingPlace类声明和接口函数,以及重载的Write函数
#include "lk_stack.h" #include "lk_list.h"
struct VehicleType {
unsigned int num; unsigned int time; };
7
StoppingPlace类的构造函数
StoppingPlace::StoppingPlace(int n,int r) {
maxNumOfStopVehicle=n; rate=r; pStopPath=new LinkStack<VehicleType>; pShortcutPath=new LinkList<VehicleType>; }
相关主题