Skip to content

Commit 271c0ff

Browse files
committed
Refactor counter as roll_counter
1 parent ee2e5a3 commit 271c0ff

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

GameDie.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77
GameDie::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
1717
GameDie::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
3535
int 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)
4444
vector <int> GameDie::get_distribution(){
45-
return counter;
45+
return roll_counter;
4646
}

GameDie.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)