Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The word scramble game is similar to the dice game, except that it is played wit

ID: 3528722 • Letter: T

Question

The word scramble game is similar to the dice game, except that it is played with random letters. As above, these should be stored as a vector of Spinner objects. Each letter should be represented by a spinner that labels and values corresponding to standard Scrabble letters and point values as listed HERE. The user starts with 0 points, and the game proceeds as follows: Fill the vector with 10 Spinner objects. Spin them to set up 10 random letters, then display their labels side-by-side on one line. Repeatedly prompt the user to enter a word. For each word they enter: If the word can be formed from the letters showing in the list (WITHOUT using a letter more than once), give the player points equal to the sum of all the letters' values. Then REMOVE the corresponding spinner objects from the vector. Otherwise, do nothing - just report that the user's play is invalud. After each play, re-display the current list of letters and report the player's current score. When the player enters nothing (" ") instead of a word, end the game.

Explanation / Answer

#include #include #include #include using namespace std; int main() { enum fields {WORD, HINT, NUM_FIELDS}; const int NUM_WORDS = 5; const int MAX_GUESSES = 5; const string WORDS[NUM_WORDS][NUM_FIELDS] = { {"wall", "Do you feel you're banging your head against something?"}, {"glasses", "These might help you see the answer."}, {"labored", "Going slowly, is it?"}, {"persistent", "Keep at it."}, {"jumble", "It's what the game is all about."} }; string guess; int points = 0; char another; do { system("cls"); srand(time(0)); int choice = (rand() % NUM_WORDS); string theWord = WORDS[choice][WORD]; // word to guess string theHint = WORDS[choice][HINT]; // hint for word string jumble = theWord; // jumbled version of word int length = jumble.size(); for (int i=0; i