//queue.h
//queue.cppCode:#ifndef QUEUE_H_ #define QUEUE_H_ #include <string> using namespace std; class Queue { public: bool IsEmptyQueue(void) const; bool IsFullQueue(void) const; void initializeQueue(void); int Myfront(void) const; int Myback(void) const; void addQueue( int); void removeQueue(void); Queue(int); ~Queue(void); void PrintNumber(void); void PrintQueueNumber(void); private: int maxQueuesize; int count; int front; int back; int * list; }; #endif
main.cppCode:#ifndef QUEUE_H_ #define QUEUE_H_ #include <string> using namespace std; class Queue { public: bool IsEmptyQueue(void) const; bool IsFullQueue(void) const; void initializeQueue(void); int Myfront(void) const; int Myback(void) const; void addQueue( int); void removeQueue(void); Queue(int); ~Queue(void); void PrintNumber(void); void PrintQueueNumber(void); private: int maxQueuesize; int count; int front; int back; int * list; }; #endif
I need help, i am cuurently designing a queue system for a clinic. Right now, i have a problem. I want to ask the user toenter a Id and their name and store their particular into the queue. But right now, my class function addQueue only store the ID number but not the name. How should i do it such that the function can store both the name and the ID number and store it into the queue system.Code:#include <iostream> #include <string> #include "Queue.h" using namespace std; void main(void) { int mySize; //the amount of queue for the clinic int number; string name; int Id; cout << "Enter the queue you want for the maximum for the clinic: " ; cin >> mySize; cout << endl; while (mySize <= 0) { cout << "Please enter number greater than 0: " ; cin >> mySize; cout << endl; } Queue * theQueue = new Queue(mySize); system ("cls"); cout << "Welcome to my Clinic queuing system!" << endl; cout << "-Press <1> to get a queue number" << endl; cout << "-Press <2> to get the first patient in the queue" << endl; cout << "-Press <3> to print all in the queue" << endl; cout << "-Press <4> to exit from this program" << endl; cin >> number; while (number <= 0 || number > 4) { cout << "Wrong input! Enter again: "; cin >> number; } if (number == 1) { system ("cls"); cout << "Welcome to my Clinic queuing system!" << endl; cout << "Enter your name: " ; cin >> name; cout << "Enter your ID: "; cin >> Id; theQueue ->addQueue( Id); theQueue ->PrintQueueNumber(); } system ("pause"); }
Example something like this:
Queue number 0:
Name: Tomy
ID: 23456
Queue number 1:
Name: Rachel
ID: 12345
Currently my class only store Id into the queue system. I want to store the name too. My menu syetm is still halfway done but all my solution is working perfectly, just the question i got problem. I did try to add a string into the addQueue class function together with the ID but not sure how to code it into the queue.cpp file there.



1Likes
LinkBack URL
About LinkBacks



