// departEvent.C: the Departure class. (modified from depart.cc)

#include "supermarket.h"
#include "departEvent.h"

// makeItHappen: departure event routine.
void DepartureEvent::makeItHappen () {
   // precondition: cashier!= null && cashier->getCustInService != null
   
   // Identify the departing customer and collect statistics.
   Cust *departingCust = cashier->getCustInService();
   sim->addItemsSold( departingCust->getItemsBought() );
   
   // The cust vanishes and the cashier is free; can we serve another
   // customer?
   delete departingCust;

   if (cashier->getCustQueue()->getQueueSize() > 0)
      cashier->startService(cashier->getCustQueue()->takeFirstCust());
   else
      cashier->endService(); // makes cashier available 

   // This departure event is all done.
   delete this;
}
