//----------------------------------------------------------------------
//  theater.cpp
//  This program simulates a movie theater queue, where customers
//  attend either movie A or movie B
//----------------------------------------------------------------------
#include "rand2.h"
#include "cqueue.h"
#include <iostream.h>

int main()
{
    CharQueue theaterQ;
    RandGen   rGen;
    int       timeUnit;
    int       turnedAway = 0;
    int       numA = 0;
    int       numB = 0;
    char      movieChoice;      // 'A' or 'B'

    for (timeUnit = 1; timeUnit <= 180; timeUnit++) {
        if ( !theaterQ.IsEmpty() ) {
            if (theaterQ.Front() == 'A')
                numA++;
            else
                numB++;
            theaterQ.Dequeue();
        }
        if (rGen.NextRand() <= 0.7)
            if (theaterQ.IsFull())
                turnedAway++;
            else {
                movieChoice = 'A' + int(rGen.NextRand()*2.0);
                theaterQ.Enqueue(movieChoice);
            }
    }
    cout << "Theater A customers: " << numA << '\n';
    cout << "Theater B customers: " << numB << '\n';
    cout << "No. turned away: " << turnedAway << '\n';

    return 0;
}


