/*** Saeteurn, San ect_sfs@ecst.csuchico.edu 15b Program 5: Kwik-E-Mart Simulator ***/ #include "store.h" void Store::runSimulator(ostream &os,int numCheckers) { Pqueue check; int checkSize = 0; Cust *checkers[numCheckers]; int checkCash[numCheckers]; string name; bool type; int aTime,items,priority; for(int i=0;i0&&igetDep()==clock) { if(checkers[i]->getType()==true) { checkSize--; Cust *tmp = checkers[i]; checkCash[i] += checkers[i]->getItem()*2; checkers[i]->print(os); checkers[i] = NULL; delete tmp; } else { checkSize--; Cust *tmp = checkers[i]; checkers[i]->setPrice(checkCash[i]); checkCash[i] = 0; checkers[i]->print(os); checkers[i] = NULL; delete tmp; } } } //Stage 1: Getting people out of the waiting to enter line to the waiting to leave line while(m_custWait.empty()==false && m_custWait.getPriority()==clock) { if(m_custWait.dequeue(name,type,aTime,items,priority)==false)//Check if dequeue was successful { break; } if(check.enqueue(name,type,aTime,items,aTime + items)==false)//Check if enqueue is successful { break; } } //Stage 2: Taking customers out of the waiting to leave line and assignes them to a customer while(checkSizesetCheck(i); checkers[i]->setDep(clock + items); checkSize++; break; } } } //Stage 4: Checking to see If it is done if(check.empty() && m_custWait.empty() && checkSize==0) { break; } } } bool Store::insert(string name,bool type,int Atime,int items,int priority) { return m_custWait.enqueue(name,type,Atime,items,priority); }