wheelsmanx

CPS 272 QUEUE

Nov 29th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <queue>
  2. #include <string>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. class personInLine {
  8. public:
  9. int waitTime;
  10. };
  11.  
  12. class sim {
  13. public:
  14. queue<personInLine> persons;
  15. int timeFromZero = 0;
  16. int targetTime = 120;
  17. int numberOfPeopleServed = 0;
  18. int numberOfPeopleInline = 0;
  19. int nextArrivalTime = 0;
  20. sim() {
  21. while (timeFromZero < targetTime) {
  22. minute();
  23. //add person to line
  24. if (timeFromZero == nextArrivalTime) {
  25. nextArrival(); ;
  26. }
  27.  
  28. }
  29. }
  30. void minute() {
  31. timeFromZero++;
  32. }
  33. void nextArrival(personInLine input) {
  34. personInLine newPerson;
  35. persons.push(newPerson);
  36. }
  37. void addPersonToLine() {
  38. numberOfPeopleInline++;
  39. }
  40. void personLeftLine() {
  41. numberOfPeopleServed++;
  42. }
  43. void nextCustomer() {
  44. cout << "Next Customer" << endl;
  45. cout << "Total Time To Server: " << endl;
  46. cout << "Scheduling next customer " << endl;
  47. }
  48. };
Advertisement
Add Comment
Please, Sign In to add comment