#include "Game.h"
#include "Bag.h"
#include "Ball.h"
#include <cstdlib> // srand()
#include <ctime> // time()
#include <iostream>
using namespace std;

void main()
{
    int   i;
    Game  theGame;
    Bag  *pickedBag;
    Ball *firstPickedBall, *secondPickedBall;
    int   totalCount = 0;
    int   secondIsAlsoRed = 0;

    srand(time(0));

    for (i=0; i<10000; i++)
    {
        pickedBag = theGame.getABag();
        firstPickedBall = pickedBag->getABall();
        if (firstPickedBall->isRed())
        {
            totalCount++;
            if ((secondPickedBall=pickedBag->getABall())->isRed())
                secondIsAlsoRed++;
            pickedBag->putABallBack(secondPickedBall);
        }
        pickedBag->putABallBack(firstPickedBall);
    }

    cout << "The probability that remaining ball is red = " 
         << ((double)secondIsAlsoRed/totalCount) << "\n";
}