File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77GameDie::GameDie ()
88{
99 srand (time (NULL ));
10- counter .resize (FACES);
10+ roll_counter .resize (FACES);
1111
1212 for (int i=0 ; i<FACES; i++)
13- counter [i] = 0 ;
13+ roll_counter [i] = 0 ;
1414}
1515
1616// overloaded constructor
1717GameDie::GameDie (unsigned int num)
1818{
1919 if ( num == 0 )
2020 {
21- counter .resize (FACES);
21+ roll_counter .resize (FACES);
2222 }
2323 else {
24- counter .resize (num);
24+ roll_counter .resize (num);
2525 }
2626 for (int i=0 ; i<FACES; i++)
2727 {
28- counter [i] = 0 ;
28+ roll_counter [i] = 0 ;
2929 }
3030
3131}
@@ -34,13 +34,13 @@ GameDie::GameDie(unsigned int num)
3434// (inclusive) and return it
3535int GameDie::roll ()
3636{
37- int roll = rand () % counter .size ();
38- counter [roll]++;
37+ int roll = rand () % roll_counter .size ();
38+ roll_counter [roll]++;
3939 return roll + 1 ;
4040}
4141
4242// return the count of how many times each face has been rolled, as a vector
4343// where each face's count is at index face-1 (i.e. Face 1 is at index 0)
4444vector <int > GameDie::get_distribution (){
45- return counter ;
45+ return roll_counter ;
4646}
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class GameDie
1313 vector <int > get_distribution ();
1414
1515 private:
16- vector <int > counter ;
16+ vector <int > roll_counter ;
1717 const static int FACES = 6 ;
1818};
1919
You can’t perform that action at this time.
0 commit comments