#include #include #include // precondition: srand() must be called once before any CUSTOMER methods are used // postcondition: arrive(void) returns a random integer between 1 and 15 // : gallons(void) returns a random integer between 3 and 20 #include // note use of full path name here #include // again - a full path name is used const float SIMTIME = .5; // simulation time in hours const int MINUTES = 60; // number of minutes in an hour const float AMT_IN_TANK = 300; // initial gallons in the tank const float TODAYS_PRICE = 1.25; // price-per-gallon int main() { Pump a(AMT_IN_TANK, TODAYS_PRICE); // declare 1 object of type Pump Customer *anotherCust; // declare 1 pointer to an object of type Customer int totalTime = 0; int idleTime; int amtRequest; int SimMinutes; // simulation time in minutes SimMinutes = SIMTIME * MINUTES; cout << "\nStarting a new simulation - simulation time is " << SimMinutes << " minutes" << endl; a.values(); srand(time(NULL)); // create a new object of type Customer anotherCust = new Customer; // get the customer's arrival time idleTime = anotherCust->arrive(); totalTime += idleTime; while (totalTime <= SimMinutes) { cout << "The idle time is " << idleTime << " minutes" << endl << " and we are " << totalTime << " minutes into the simulation." << endl; amtRequest = anotherCust->gallons(); a a.request(float(amtRequest)); // delete this Customer delete anotherCust; // create the next Customer anotherCust = new Customer; // get the next arrival idleTime = anotherCust->arrive(); totalTime += idleTime; } cout << "The idle time is " << idleTime << " minutes." << endl << "\nAs the total time now exceeds the simulation time, " << endl << " this simulation run is over." << endl; return 0; }