/*==== SimulationValues.h ===================================
Struct SimulationValues maintains important simulation values.
=============================================================*/

#include <iostream>          // istream, ostream, >>, <<
#include <cstdlib>           // srand()
#include <ctime>             // time()
using namespace std;

struct SimulationValues
{
/***** Data Members *****/
   static const int NUM_LIMITS = 4;
   // Inputs
   double arrivalRate;
   int servicePercent[NUM_LIMITS],
       lengthOfSimulation;
   // Outputs
   int callsReceived;
   double totalWaitingTime;

/***** Function Members *****/
/*** Constructor
  Postcondition: Output data members are initialized to 0
                 and random number generator is seeded
---------------------------------------------------------*/
SimulationValues()
{
  callsReceived = 0;
  totalWaitingTime = 0;
  srand(long(time(0)));          // use clock for seed
}

/*** Input
  Input: Arrival rate, percentages for service times,
         and time limit for simulation
  Postcondition: Input data members are set.
---------------------------------------------------------*/
void Read(istream & in);

/*** Output
  Output: total number of call and the average
          waiting time for calls
---------------------------------------------------------*/
void Display(ostream & out)
{
  out << "\nNumber of calls processed:   " << callsReceived
      << "\nAve. waiting time per call:  "
      <<      totalWaitingTime / callsReceived
      << endl;
}
};  // end of class declaration

/***** Definition of Read() *****/
void SimulationValues::Read(istream & in)
{
  cout << "Enter arrival rate: ";
  in >> arrivalRate;
  cout << "Enter percent of calls serviced in\n";
  int perc,
      sum = 0;
  for (int i = 0; i < NUM_LIMITS; i++)
  {
    cout << "  < " << i + 1 << " min. ";
    in >> perc;
    sum += perc;
    servicePercent[i] = sum;
  }
  servicePercent[NUM_LIMITS] = 1;
  cout << "Enter # of minutes to run simulation: ";
  in >> lengthOfSimulation;
}

