int calcScore (Hand *hand, int row) { ɩnt score - 0; ɩnt diceCount[0] = {}; for (int i=0; i < HAND_SIZE; \++) { int value-hand->getDice()->reveal(); diceCount[value - 1]++; } LT (row > ONES && row <- SIXES) { score diceCount[row] * (row + 1); } else if (row -- THREE_OF_KIND || row -- FOUR_OF_KIND || row -- CHANCE || row -- YAHTZEE) { int sum - 8; for (int 1-8; 1 < 0; 1++) { } sum += (1 + 1) * diceCount[1]; if (row -- THREE _OF_KIND || row -- FOUR_OF_KIND) { bool valid = false; for (int count diceCount) { if ((row -- THREE OF KIND & (row == FOUR OF KIND & valid = true; count >= 3) || count >= 4)) { break; } } score - valid ? sum = 0; } else if (row -- CHANCE) { score - sun; } else if (row -- YAHTZEE) { for (int count = diceCount) { if (count == 5) { score = 30; break; } } } else if (row == FULL_HOUSE) { bool hasThree = false; bool hasTwo = false; for (int count = diceCount) { if (count == 3) has Three = true; if (count == 2) hasTwo = true; } score (hasThree && hasTwo) ? 25 = 0; } else if (row -- SMALL_STRAIGHT) { int consecutive - 8; for (int 1-8; 1 < 6; 1++) { } consecutive - (diceCount[1] > 0) ? (consecutive + 1) = 0; if (consecutive -- 4) { } score = 30; break; } else if (row -- LARGE STRAIGHT) { if (diceCount[0] -- 1 && diceCount[1] — 1 && diceCount [2] -- 1 66 diceCount[3] -- 1 && diceCount[4] -- 1 || (diceCount[1] -- 1 && diceCount[2] = 1 && diceCount[3] -=- 1 && diceCount [4] -- 1 && diceCount[5] = 1}} { score - 40; } return score; int getUpperScore() { } int upperScore 0; for (int i = ONES; i <= SIXES; i++) { } upperScore += score[i]; return upperScore; // 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; return (getUpperScore() >= UPPER_SCORES_THRESHOLD) ? BONUS_POINTS : 0; // Returns the total score int getTotalScore() { } return getUpperScore() + getLowerScore() + getBonusScore();
int calcScore (Hand *hand, int row) { ɩnt score - 0; ɩnt diceCount[0] = {}; for (int i=0; i < HAND_SIZE; \++) { int value-hand->getDice()->reveal(); diceCount[value - 1]++; } LT (row > ONES && row <- SIXES) { score diceCount[row] * (row + 1); } else if (row -- THREE_OF_KIND || row -- FOUR_OF_KIND || row -- CHANCE || row -- YAHTZEE) { int sum - 8; for (int 1-8; 1 < 0; 1++) { } sum += (1 + 1) * diceCount[1]; if (row -- THREE _OF_KIND || row -- FOUR_OF_KIND) { bool valid = false; for (int count diceCount) { if ((row -- THREE OF KIND & (row == FOUR OF KIND & valid = true; count >= 3) || count >= 4)) { break; } } score - valid ? sum = 0; } else if (row -- CHANCE) { score - sun; } else if (row -- YAHTZEE) { for (int count = diceCount) { if (count == 5) { score = 30; break; } } } else if (row == FULL_HOUSE) { bool hasThree = false; bool hasTwo = false; for (int count = diceCount) { if (count == 3) has Three = true; if (count == 2) hasTwo = true; } score (hasThree && hasTwo) ? 25 = 0; } else if (row -- SMALL_STRAIGHT) { int consecutive - 8; for (int 1-8; 1 < 6; 1++) { } consecutive - (diceCount[1] > 0) ? (consecutive + 1) = 0; if (consecutive -- 4) { } score = 30; break; } else if (row -- LARGE STRAIGHT) { if (diceCount[0] -- 1 && diceCount[1] — 1 && diceCount [2] -- 1 66 diceCount[3] -- 1 && diceCount[4] -- 1 || (diceCount[1] -- 1 && diceCount[2] = 1 && diceCount[3] -=- 1 && diceCount [4] -- 1 && diceCount[5] = 1}} { score - 40; } return score; int getUpperScore() { } int upperScore 0; for (int i = ONES; i <= SIXES; i++) { } upperScore += score[i]; return upperScore; // 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; return (getUpperScore() >= UPPER_SCORES_THRESHOLD) ? BONUS_POINTS : 0; // Returns the total score int getTotalScore() { } return getUpperScore() + getLowerScore() + getBonusScore();
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
- Test 10: Check upper board and having bonus correctly (0/3)
- Test 11: Check upper board and not having bonus correctly (0/3)
![int calcScore (Hand *hand, int row) {
ɩnt score - 0;
ɩnt diceCount[0] = {};
for (int i=0; i < HAND_SIZE; \++) {
int value-hand->getDice()->reveal();
diceCount[value - 1]++;
}
LT (row > ONES && row <- SIXES) {
score diceCount[row] * (row + 1);
} else if (row -- THREE_OF_KIND || row -- FOUR_OF_KIND || row -- CHANCE ||
row -- YAHTZEE) {
int sum - 8;
for (int 1-8; 1 < 0; 1++) {
}
sum += (1 + 1) * diceCount[1];
if (row -- THREE _OF_KIND || row -- FOUR_OF_KIND) {
bool valid = false;
for (int count diceCount) {
if ((row -- THREE OF KIND &
(row == FOUR OF KIND &
valid = true;
count >= 3) ||
count >= 4)) {
break;
}
}
score - valid ? sum = 0;
} else if (row -- CHANCE) {
score - sun;
} else if (row -- YAHTZEE) {
for (int count = diceCount) {
if (count == 5) {
score = 30;
break;
}
}
} else if (row == FULL_HOUSE) {
bool hasThree = false;
bool hasTwo = false;
for (int count = diceCount) {
if (count == 3)
has Three = true;
if (count == 2)
hasTwo = true;
}
score (hasThree && hasTwo) ? 25 = 0;
} else if (row -- SMALL_STRAIGHT) {
int consecutive - 8;
for (int 1-8; 1 < 6; 1++) {
}
consecutive - (diceCount[1] > 0) ? (consecutive + 1) = 0;
if (consecutive -- 4) {
}
score = 30;
break;
} else if (row -- LARGE STRAIGHT) {
if (diceCount[0] -- 1 && diceCount[1] — 1 && diceCount [2] -- 1 66
diceCount[3] -- 1 && diceCount[4] -- 1 ||
(diceCount[1] -- 1 && diceCount[2] = 1 && diceCount[3] -=- 1 &&
diceCount [4] -- 1 && diceCount[5] = 1}} {
score - 40;
}
return score;](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd0dac0b6-5a17-4cd9-bac9-9e2e50ac9cbc%2F7a2b371b-bf7a-43e0-987b-90346d3c2d67%2F0lkzdw7_processed.png&w=3840&q=75)
Transcribed Image Text:int calcScore (Hand *hand, int row) {
ɩnt score - 0;
ɩnt diceCount[0] = {};
for (int i=0; i < HAND_SIZE; \++) {
int value-hand->getDice()->reveal();
diceCount[value - 1]++;
}
LT (row > ONES && row <- SIXES) {
score diceCount[row] * (row + 1);
} else if (row -- THREE_OF_KIND || row -- FOUR_OF_KIND || row -- CHANCE ||
row -- YAHTZEE) {
int sum - 8;
for (int 1-8; 1 < 0; 1++) {
}
sum += (1 + 1) * diceCount[1];
if (row -- THREE _OF_KIND || row -- FOUR_OF_KIND) {
bool valid = false;
for (int count diceCount) {
if ((row -- THREE OF KIND &
(row == FOUR OF KIND &
valid = true;
count >= 3) ||
count >= 4)) {
break;
}
}
score - valid ? sum = 0;
} else if (row -- CHANCE) {
score - sun;
} else if (row -- YAHTZEE) {
for (int count = diceCount) {
if (count == 5) {
score = 30;
break;
}
}
} else if (row == FULL_HOUSE) {
bool hasThree = false;
bool hasTwo = false;
for (int count = diceCount) {
if (count == 3)
has Three = true;
if (count == 2)
hasTwo = true;
}
score (hasThree && hasTwo) ? 25 = 0;
} else if (row -- SMALL_STRAIGHT) {
int consecutive - 8;
for (int 1-8; 1 < 6; 1++) {
}
consecutive - (diceCount[1] > 0) ? (consecutive + 1) = 0;
if (consecutive -- 4) {
}
score = 30;
break;
} else if (row -- LARGE STRAIGHT) {
if (diceCount[0] -- 1 && diceCount[1] — 1 && diceCount [2] -- 1 66
diceCount[3] -- 1 && diceCount[4] -- 1 ||
(diceCount[1] -- 1 && diceCount[2] = 1 && diceCount[3] -=- 1 &&
diceCount [4] -- 1 && diceCount[5] = 1}} {
score - 40;
}
return score;
![int getUpperScore() {
}
int upperScore
0;
for (int i = ONES; i <= SIXES; i++) {
}
upperScore += score[i];
return upperScore;
// 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;
return (getUpperScore() >= UPPER_SCORES_THRESHOLD) ? BONUS_POINTS : 0;
// Returns the total score
int getTotalScore() {
}
return getUpperScore() + getLowerScore() + getBonusScore();](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd0dac0b6-5a17-4cd9-bac9-9e2e50ac9cbc%2F7a2b371b-bf7a-43e0-987b-90346d3c2d67%2Fpzamxzi_processed.png&w=3840&q=75)
Transcribed Image Text:int getUpperScore() {
}
int upperScore
0;
for (int i = ONES; i <= SIXES; i++) {
}
upperScore += score[i];
return upperScore;
// 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;
return (getUpperScore() >= UPPER_SCORES_THRESHOLD) ? BONUS_POINTS : 0;
// Returns the total score
int getTotalScore() {
}
return getUpperScore() + getLowerScore() + getBonusScore();
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education