Why is my code not dequeueing here:
Code:if(arrive != i) { Queue.Enqueue(customer); //i = arrive; } else if(arrive == i) { Queue.Dequeue(); service = rand()%100; Outfile<<service<<endl; } //******************************************************************// //Program Queue client file // // // // // // // // // // // // // //******************************************************************// #include<iostream> #include<iomanip> #include<fstream> #include<cstdlib> #include"Queue.h" #include"QueueImpl.cpp" const int loopcounter = 200; using namespace std; //int CalculateTime(int service); int main() { IntQueue Queue; ifstream Infile; ofstream Outfile; Infile.open("inputQ.txt"); Outfile.open("OUTPUTQ.TXT"); int y = rand(); int x = rand(); int minutes = 720; int arrive, service, currentperson_time, nextperson, NextCustomer; int arrivaltimenewcust, servicetimeNew, oldValue; int MaxCust= 3; int i = 0; int customer = 0; int CustomerNumber=0; int runningtime; int time=0; y = rand(); x = rand(); Infile>>customer; while(i < loopcounter ) { i++; //Infile>>customer; CustomerNumber = customer; srand(customer); arrive = rand()%100; //First cutsomer arrival time service = rand()%100; //First customer service time if(arrive != i) { Queue.Enqueue(customer); //i = arrive; } else if(arrive == i) { Queue.Dequeue(); service = rand()%100; Outfile<<service<<endl; } Outfile<<"Customer "<<customer<<endl; Outfile<<"Customer "<<customer<<" arrival time "<<arrive<<endl; Outfile<<"Customer "<<customer<<" service time "<<service<<endl; customer++; } Infile>>customer; return 0; } //Implementation #include<stddef.h> typedef NodeType* NodePtr; struct NodeType { int data; NodePtr link; }; //////////////////////////////////////////////////////////////////// void CopyList(NodePtr, NodePtr&, NodePtr&); IntQueue::IntQueue() { front = rear = NULL; } //////////////////////////////////////////////////////////////////// IntQueue::~IntQueue() { NodePtr tempPtr; while(front != NULL) { tempPtr = front; front = tempPtr->link; delete tempPtr; } } ///////////////////////////////////////////////////////////////////// IntQueue::IntQueue(const IntQueue& otherQ) { if(otherQ.front == NULL) front = rear = NULL; else CopyList(otherQ.front, front, rear); } ////////////////////////////////////////////////////////////////////// void IntQueue::Enqueue(int newItem) { NodePtr newPtr = new NodeType; newPtr->data = newItem; newPtr->link = NULL; if(front == NULL) front = rear = newPtr; else{ rear->link = newPtr; rear = newPtr; } } ////////////////////////////////////////////////////////////////////// int IntQueue::Front() const { return front->data; } ////////////////////////////////////////////////////////////////////// void IntQueue::Dequeue() { NodePtr tempPtr = front; front = tempPtr->link; delete tempPtr; if(front == NULL) rear = NULL; } ////////////////////////////////////////////////////////////////////// void CopyList(NodePtr currPtr, NodePtr& cloneFront, NodePtr& cloneRear) { NodePtr newPtr = NULL; { CopyList(currPtr->link, cloneFront, cloneRear); newPtr = new NodeType; newPtr->data = currPtr->data; newPtr->link = cloneFront; if(currPtr->link == NULL) cloneRear = newPtr; } cloneFront = newPtr; } //header struct NodeType; class IntQueue { public: IntQueue(); IntQueue(const IntQueue& otherQ); void Enqueue(int newItem); int Front() const; void Dequeue(); ~IntQueue(); private: NodeType* front; NodeType* rear; };



LinkBack URL
About LinkBacks



