// banksim.cpp -- Bank Simulation using a queue & random numbers
//                Dave Reed    davereed@creighton.edu
//////////////////////////////////////////////////////////////////////


#include "ServiceCenter.h"
#include "Die.h"

bool CustomerArrived(int arrivalProb);          

void main()
{
    int maxTime, arrivalProb;
    cout << "What is the time duration (in minutes) to be simulated? ";
    cin >> maxTime;
    cout << "What percentage of the time (0-100) does a customer arrive? ";
    cin >> arrivalProb;
    cout << endl;

    ServiceCenter bank;
    for (int time = 1; time <= maxTime || bank.customersBeingServed() ||                                           bank.customersWaiting(); time++) {
        if ( time <= maxTime && CustomerArrived(arrivalProb) ) {
            bank.addCustomer();
        }
        bank.serveCustomers();
    }
}

//////////////////////////////////////////////////////////////////////

bool CustomerArrived(int arrivalProb)
// Assumes: 0 <= arrivalProb <= 100
// Returns: true with probability ARRIVAL_PROB, else false
{
    Die d(100);
    return (d.Roll() <= arrivalProb);
}
