#include <iostream>
using namespace std;
#include "dice.h"
#include "prompt.h"

// illustrates cumbersome programming 
// roll two dice and track occurrences of all possible rolls

const int DICE_SIDES = 4;

int main()
{
    int twos=    0;                   // counters for each possible roll
    int threes=  0;
    int fours=   0;
    int fives=   0;
    int sixes=   0;
    int sevens=  0;
    int eights=  0;
    
    int rollCount = PromptRange("how many rolls",1,20000);
    Dice d(DICE_SIDES);
    
    int k;    
    for(k=0; k < rollCount; k++)        // simulate all the rolls
    {   int sum = d.Roll() + d.Roll();
        switch (sum)
        {
          case 2:
            twos++;
            break;
          case 3:
            threes++ ;
            break;
          case 4:
            fours++;
            break;
          case 5:
            fives++;
            break;
          case 6:
            sixes++;
            break;
          case 7:
            sevens++;
            break;
          case 8:
            eights++;
            break;
        }
    }
    // output for each possible roll # of times it occurred
    
    cout << "roll\t# of occurrences" << endl;    
    cout << "2\t" << twos   << endl;
    cout << "3\t" << threes << endl;    
    cout << "4\t" << fours  << endl;
    cout << "5\t" << fives  << endl;
    cout << "6\t" << sixes  << endl;
    cout << "7\t" << sevens << endl;
    cout << "8\t" << eights << endl;

    return 0;
}
