// stats.h: the Statistics class, for objects that collect statistics. // (There is only one such object in this program.) class Statistics { private: // The explicit initializations are not needed, but improve clarity. int totalArrivals; int customersServed; int balkingCustomers; double totalLitresSold; double totalLitresMissed; double totalWaitingTime; double totalServiceTime; static void printHeaders (); public: // Constructor. // The list of "name (value)" pairs after the colon and before the // constructor body provides initial values for those data members. Statistics () : totalArrivals (0), customersServed (0), balkingCustomers (0) , totalLitresSold (0.0), totalLitresMissed (0.0), totalWaitingTime (0.0), totalServiceTime (0.0) { printHeaders(); } // accumBalk: record and count a lost sale. void accumBalk (double litres); // accumSale: record and count a sale. void accumSale (double litres); // accumServiceTime: record a customer's service time. void accumServiceTime (double interval); // accumWaitingTime: record a customer's waiting time. void accumWaitingTime (double interval); // countArrival: record an arrival. void countArrival (); // snapshot: print a summary of the statistics so far. void snapshot (); };