arriveevent.h

来自「数据结构」· C头文件 代码 · 共 46 行

H
46
字号
#ifndef _arriveEvent
#define _arriveEvent

#include"event.h"
#include"random.h"
#include"orderEvent.h"
#include"simulation.h"
#include"customerGroup.h"
#include"storeSimulation.h"

#include<assert.h>
#include<iostream.h>


class arriveEvent:public event//到达事件
{
  public:
	  arriveEvent(unsigned int,customerGroup*);
	  virtual void processEvent();
  private:
	  customerGroup* group;
};


arriveEvent::arriveEvent(unsigned int time1,customerGroup*  gup):group(gup),event(time1)
{
}

void arriveEvent::processEvent()
{
	int hours,minuters;
	hours=time/60+8;
	minuters=time%60;
	cout<<hours<<"点"<<minuters<<"分钟"<<"    "<<"有"<<group->groupsize<<"人到达."<<endl;
	if(group->groupsize<store.freeChairs)
	{
		store.freeChairs-=group->groupsize;
		event*oe=new orderEvent(time+randgen.between(2,10),group);
		assert(oe!=0);
		store.scheduleEvent(oe);
    }
    else
        cout<<"没有剩余座位,顾客离去.\n";
}    
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?