int getUpperScore(){ int upperScore = 0; for(int i = ONES; i <= SIXES; i++){ upperScore += score[i]; } return upperScore + getBonusScore(); } //Returns the score of the upper part of the board int getLowerScore(){ int lowerScore = 0; for(int i = THREE_OF_KIND; i <= YAHTZEE; i++){ lowerScore += score[i]; } return lowerScore; } //Returns the bonus points int getBonusScore(){ const int UPPER_SCORES_THRESHOLD = 63; const int BONUS_POINTS = 35; if(getUpperScore() >= UPPER_SCORES_THRESHOLD){ return BONUS_POINTS; } return 0; } //Returns the total score int getTotalScore(){ return getUpperScore() + getLowerScore(); } Test 10: Check upper board and having bonus correctly (0/3) failed
int getUpperScore(){
int upperScore = 0;
for(int i = ONES; i <= SIXES; i++){
upperScore += score[i];
}
return upperScore + getBonusScore();
}
//Returns the score of the upper part of the board
int getLowerScore(){
int lowerScore = 0;
for(int i = THREE_OF_KIND; i <= YAHTZEE; i++){
lowerScore += score[i];
}
return lowerScore;
}
//Returns the bonus points
int getBonusScore(){
const int UPPER_SCORES_THRESHOLD = 63;
const int BONUS_POINTS = 35;
if(getUpperScore() >= UPPER_SCORES_THRESHOLD){
return BONUS_POINTS;
}
return 0;
}
//Returns the total score
int getTotalScore(){
return getUpperScore() + getLowerScore();
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images