arriveevent.cpp

来自「产生一个随机数」· C++ 代码 · 共 29 行

CPP
29
字号
#include<iostream.h>
#include"event.h"
#include"arriveEvent.h"
#include"leaveEvent.h"
#include"orderEvent.h"
#include<assert.h>
#include<stdlib.h>
#include"customerGroup.h"
#include"simulation.h"
#include"storeSimulation.h"
#include"random.h"
extern storeSimulation store;
arriveEvent::arriveEvent(unsigned int t,customerGroup* g)
                     :group(g),event(t)
                     {}
void arriveEvent::processEvent()
{      
		random m_randomvalue;
     cout<<"Customer group of size "<<group->groupsize
         <<" , arrives at time"<<time<<'\n';
     if(group->groupsize<store.freeChairs){
          store.freeChairs-=group->groupsize;
          event*oe=new orderEvent(time+m_randomvalue.between(2,8),group);
          assert(oe!=0);
          store.scheduleEvent(oe);
     }
     else
         cout<<"No  space:group leaves.\n";
}                                         

⌨️ 快捷键说明

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