rendered paste body/* * Dice.cpp * * Assignment 4, Craps * SID: 995050550 * Author: Crystal Tse * Due: February 17, 2009 * Class: ECS 40, Winter 2009 */#include <iostream>#include <fstream>using namespace std;#include "Dice.h"#include <stdio.h>#include <stdlib.h>#include <time.h>Dice :: Dice() // default constructor{ d1 = -1; d2 = -1; sum = 0; for(int i=0; i<13; i++) diceRoll[i] = 0; srand(time(NULL));}Dice :: ~Dice() // destructor{}int Dice :: roll() // returns roll value of the dice{ d1 = rand()%6 + 1; // uses rand() to generate random value for the die, between 1 and 6 d2 = rand()%6 + 1; // uses rand() to generate random value for the die, between 1 and 6 sum = d1 + d2; diceRoll[sum]++; return ( d1 + d2 ); // returns the total roll for the pair of dice}void Dice :: getProbability(){ DiceData.open("Dicedata.txt"); DiceData << "Dice Value \t Times Rolled"<<endl; for(int i=2; i<13; i++) { DiceData << i << " \t " << diceRoll[i] << endl; } DiceData.close();}