-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Labels
Description
get_distribution() keeps a tally of how many times each face has been rolled, but some users are reporting that they want this same information as a percentage of total rolls.
Add a public member function vector<double> GameDie::get_percentages() that returns the percentage of rolls for each face relative to the number of total rolls. Each percentage should be a double between 0 and 1 inclusively. For example, if we have a 4-sided die that has rolled each face 1 time and has the get_distribution() of:
{1,1,1,1}
then the get_percentages() function should return:
{0.25,0.25,0.25,0.25}
If there are no rolls yet, percentages should report 0 for each face in the vector. Otherwise, the percentage should be calculated by face rolls / total rolls.