Help: Queue problem

I'm working on a practice problem on Queue, it's a matching problem, a restaurant uses 2 Queues, one for incoming parties and one for tables, and seats the parties when there are tables with the exact same chair number.the program takes a list of input in the form code, name, number, hour, min, which specifies the time when a party arrives or a table opens up.
each time a party arrives the program will search through the table_waiting_for_a_party Queue for matching table, and each time a table opens up the program will search through the party_waiting_for_a_table Queue for matching party.

right now my program runs without crashing or error messages and reads the input values correctly, but skips through all the matching loops for tables and parties. can someone take a look at the code and see what might be the problem?
Thanks!

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227`` `````` #include #include #include #include #include using namespace std; struct table_party { string name; //party name or table number int num; //number of chair or people int hour; // hour table opened or party arrived int min; //min table opened or party arrived }; class Queue { public: static const int CAPACITY = 50; typedef table_party QUEUE_TYPE; Queue(); void insert(const QUEUE_TYPE&entry); table_party remove(); bool is_empty() const; bool is_full() const; private: QUEUE_TYPE data[CAPACITY]; int front, rear, count; }; Queue::Queue() { count = 0; front = -1; rear = -1; } void Queue::insert(const QUEUE_TYPE& entry) { assert(count < CAPACITY); rear = (rear + 1) % CAPACITY; // bump rear notice neat use of mod data[rear] = entry; // put in elt count++; if (front == -1) front=0; // if queue was empty - must set front } table_party Queue::remove() { QUEUE_TYPE answer; assert(count > 0); // check theres something there answer = data[front]; // front marks first elt count--; if (count == 0) { rear = -1; // if removed last elt must reset rear front = -1; } else front = (front + 1) % CAPACITY; // bump up front return answer; } bool Queue::is_empty() const { return (count == 0); } bool Queue::is_full() const { return count>=CAPACITY; } void time_waited(int &a, int &b, int &c, int &d)//prints time parked & charges { int hour_diff; int min_diff; if (d>code; while(!textfile.eof()) { cout<<"========================================="<> p.name; if (p.name == "NOBODY") { break; } else { textfile>> p.num; textfile>> p.hour; textfile>> p.min; cout<>t.name; textfile>>t.num; textfile>>t.hour; textfile>>t.min; cout<<"Table: "<> code; } system("pause"); } ``````
Last edited on
Topic archived. No new replies allowed.