int main () { DoubleLinkList A; int customerCounter = 1; int minNumber = 1; int totalSimulationTime = 0, maxIntervalEnterQueue = 0, maxIntervalServePerson = 0, timeUntilNextCustomer = 0; bool validInput = false; string trash; // Gather user input information. Prompt again if invalid input, i.e. non-numeric. while(!validInput) { cout << "Enter the length of time simulation should run (minutes): "; cin >> totalSimulationTime; if (!cin.eof() && cin.good()) validInput = true; else { cout << "Invalid input. Please try again." << endl; cin.clear(); cin >> trash; //remove the bad input from the cin stream by throwing it into the trash string } } validInput = false; while(!validInput) { cout << "Enter maximum interval between individual people entering the queue (minutes): "; cin >> maxIntervalEnterQueue; if (!cin.eof() && cin.good()) validInput = true; else { cout << "Invalid input. Please try again." << endl; cin.clear(); cin >> trash; //remove the bad input from the cin stream by throwing it into the trash string } } validInput = false; while(!validInput) { cout << "Enter maximum interval of time to serve an individual person in the queue (minutes): "; cin >> maxIntervalServePerson; if (!cin.eof() && cin.good()) validInput = true; else { cout << "Invalid input. Please try again." << endl; cin.clear(); cin >> trash; //remove the bad input from the cin stream by throwing it into the trash string } } cout << endl; maxIntervalEnterQueue--; // account for rand() mod maxIntervalServePerson--; // account for rand() mod timeUntilNextCustomer = 1+rand()%(maxIntervalEnterQueue); // initialize time until next customer A.putCustomer(customerCounter, 1, maxIntervalServePerson); // initialize first customer cout << "Minute # | Customer # | Entry Minute | Service Time Remaining | Wait Time remaining | Minutes remaining until Service is finished" << endl; for(; minNumber<=totalSimulationTime; minNumber++) { if (A.getFirstCustomer() != NULL) { // check if any customers in line if (A.getFirstCustomer()->getTimeToServe() == 0) A.dequeue(); if (A.getFirstCustomer() != NULL) // check if any customers in line A.getFirstCustomer()->decrementTimeToServe(); } if (timeUntilNextCustomer == 0) { // new customer! add to queue and reset timer timeUntilNextCustomer = 1 + rand()%(maxIntervalEnterQueue); A.putCustomer(++customerCounter, minNumber, maxIntervalServePerson); } A.getListReverse(minNumber); // print out customers in line and relevant information timeUntilNextCustomer--; } return 0; }