Fast food custom simulation training application. The trainees encounter a wide array of situations, from working with customers and handling customer complaints, to inputting order into the system. Simulation allow new employees to experience all these scenarios without any disruption to the day-to-day restaurant affairs
class event {
public:
// Construct sets time of event.
event (unsigned int t) : time (t)
{ }
// Execute event by invoking this method.
virtual void processEvent () = 0;
const unsigned int time;
};
struct eventComparator {
bool operator() (const event * left, const event * right) const {
return left->time > right->time;
}
};
class simulation {
public:
simulation () : time (0), eventQueue ()
{}
void run ();
void scheduleEvent (event * newEvent) {
eventQueue.push (newEvent);
}
unsigned int time;
protected:
std::priority_queue<event*,
std::vector<event *, std::allocator<event*> >,
eventComparator> eventQueue;
};
void simulation::run () {
while (! eventQueue.empty ()) {
event * nextEvent = eventQueue.top ();
eventQueue.pop ();
time = nextEvent->time;
nextEvent->processEvent ();
delete nextEvent;
}
}
Comments
Leave a comment