Question: Problem 1 Write a program that simulates a simplified version of the game scrabble. The program should run through the following steps: Generate a set
Problem 1
Write a program that simulates a simplified version of the game scrabble. The program should run through the following steps:
Generate a set of 7 letters for the user
Ask the user to enter his/her word
Read the users word
Check the validity of the users word, to make sure that the user has only used letters that are available.
Display the value of the word.
Terminate the program.
Constraints: your program should define and use at least the following four functions:
void generate_letter_set (int letter_set[], int size_letter_set, int num_letters)
int read_word (char word[], int max_size_word)
_Bool check_word (char word[], int size_word, int letter_set[], int size_letter_set)
int compute_word_value (char word[], int size_word)
1. void generate_letter_set (int letter_set[], int size_letter_set, int num_letters)
This function should use the approach we discussed in our class example to randomly generate a set of letters, based on the number of tiles available (as shown in the table on the side). As in regular scrabble, multiple letters of the same type can be selected, according with the total number available. For instance, since there are only 2 tiles with letter B, the function could return at most two letter Bs. The array letter_set should store the counts of how many of either A, B, C, etc. are drawn by the random generator. Parameter size_letter_set is the size of the array letter_set (this should be the
total number of characters in the alphabet). The function should use the information regarding the available number of tiles for each letter (similar to the const arrays we used in the random cards example). The num_letters parameter is for how many letters need to be drawn. Use 7 as parameter for the value of num_letters argument when calling the function (you should use a macro definition for that value).
int read_word (char word[], int max_size_word)
The function should prompt the user to enter the word, then read it (one character at a time) and store it in the array word. The function should also return the size of the word entered by the user (i.e., how many letters there were in the word). The value of the max_size_word parameter should be 7, as it is usually the case in scrabble.
_Bool check_word (char word[], int size_word, int letter_set[], int size_letter_set)
The parameter word stores the word entered by the user, size_word is the size of the word entered, letter_set is the array of counts that has been generated by function generate_letter_set and size_letter_set is the size of the array letter_set (this should be the total number of characters in the alphabet). The function should check if the word entered by the user uses proper letters from the generated letter set and should return true or false based on this evaluation.
4.int compute_word_value (char word[], int size_word)
The function should use the information from the point values for each of the letter tiles to compute the value of the word. The function should use information regarding the point values for each letter (similar to the const arrays we used in the random cards example).
Your program should run as follows (items underlined are entered by the user):
This program plays the game of scrabble.
Your letters are: A B F G I N O
Enter your word: BIG
The value of your word is: 6
Thank you for playing.
Below is an example of what your program should print if the user enters an illegal word:
This program plays the game of scrabble.
Your letters are: A G N Q R S U
Enter your word: SUNS
The word is not valid. Use your letters: A G N Q R S U
Enter your word: SUN
The value of your word is: 3
Thank you for playing.
Save your program in a file called scrabble.c.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
