Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <string>
- #include <iostream>
- #include <stdlib.h>
- #include <queue>
- using namespace std;
- class personInLine {
- public:
- int waitTime;
- int timeToGo;
- int id;
- personInLine(int a, int c) {
- this->waitTime = a;
- this->timeToGo = a;
- this->id = c;
- }
- };
- class env {
- public:
- int currentTime = 0;
- int maxTime = 120;
- int numberOfPeople = 0;
- };
- queue<personInLine> createQueue(int input) {
- queue<personInLine> returnObject;
- for (int i = 0; i < input; i++) {
- int tempInt = rand() % 4 + 1;
- personInLine ptr(tempInt, i);
- returnObject.push(ptr);
- }
- return returnObject;
- }
- env createEnv(queue<personInLine> userInput) {
- env returnObject;
- for (int i = 0; i < userInput.size(); i++) {
- if (returnObject.currentTime < returnObject.maxTime && returnObject.currentTime + userInput.front().waitTime < returnObject.maxTime) {
- returnObject.currentTime = returnObject.currentTime + userInput.front().waitTime;
- returnObject.numberOfPeople++;
- cout << "current time: "
- }
- else {
- break;
- }
- }
- return returnObject;
- }
- void main() {
- env myEnv;
- myEnv = createEnv(createQueue(1000));
- cout << "total time used for customers: " << myEnv.currentTime << endl << endl << "number of people servered: " << myEnv.numberOfPeople << endl << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment