classes

classes - } } void CTeller::HelpCustomer(CCustomer* cust) {...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include "classes.h" bool CCustomer2::Update2() { short firstAvailableTeller = 0; long firstFreeInstant = fTellerList[0]->GetNextFreeInstant(); for (short i = 0; i < fNumTellers; ++i) { if (fTellerList[i]->GetNextFreeInstant() < firstFreeInstant) firstAvailableTeller = i; } fTeller = fTellerList[firstAvailableTeller]; return (Update()); } bool CCustomer::Update () { long curTime = fClock->GetTime(); switch (fStatus) { case outside: if (fArrivalTime == curTime) { { fTeller->HelpCustomer(this); fStatus = beingServed; fInstantServed = curTime; } else { fLine->push(this); fStatus = waitingInLine; } return true; } else return false; case waitingInLine: if (fTeller->IsFree()) { fLine->pop(); fTeller->HelpCustomer(this); fStatus = beingServed; fInstantServed = curTime; return true; } else return false; case beingServed: case served: default: return false;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } } void CTeller::HelpCustomer(CCustomer* cust) { fStatus = serving; fNextFreeInstant = fClock-&gt;GetTime(); if (cust-&gt;GetTransaction() == &quot;withdrawal&quot;) fNextFreeInstant += 5; else if (cust-&gt;GetTransaction() == &quot;deposit&quot;) fNextFreeInstant += 5; else if (cust-&gt;GetTransaction() == &quot;withdrawal_deposit&quot;) fNextFreeInstant += 9; else if (cust-&gt;GetTransaction() == &quot;new_account&quot;) fNextFreeInstant += 10; else if (cust-&gt;GetTransaction() == &quot;complaint&quot;) fNextFreeInstant += 15; else if (cust-&gt;GetTransaction() == &quot;others&quot;) fNextFreeInstant += 3; fCurCustomer = cust; } bool CTeller::Update () { if (fStatus == free) return false; else if (fClock-&gt;GetTime() == fNextFreeInstant) { if (fCurCustomer) ; // do nothing fCurCustomer = NULL; fStatus = free; return true; } else return false; }...
View Full Document

Page1 / 2

classes - } } void CTeller::HelpCustomer(CCustomer* cust) {...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online