Starting from:

$20

Scrambled 1 Intro to Programming in C Assignment 3 – ScrambledUp Solution

Assignment purpose: User defined functions, character arrays, c style string member functions
Write an interactive program that will allow a user to play the game ScrambledUp. You will need to:
 Declare and use four character arrays:
o one for the “solution/answer” from the file
o one for the “scrambled word” from the file
o one for all of the “partial solution” word
o one to hold the users “word to guess”
 Declare additional variables as needed
 Preload the arrays
o “solution/answer” array - start with an empty string.
 Read the first word from the file, “scrambledwords.txt”, and store it in the solution/answer array.
o “scrambled word” array – start with an empty string
 Read the second word from the file and store it in the scrambled word array
o “partial solution” array should be adjusted to the correct length (that is the same size as the word read from the file but consists only of * (asterisks) in the beginning
o “word to guess” array should be empty – used to hold the attempt by the user to input the answer
HOW TO PLAY THE GAME
 Allow the user to select letters one character at a time for proper placement in the word.
 At every stage of the game, the user should be able to view the scrambled word and the current state of the “partial solution”.
 If a letter is added and the word is not guessed correctly, the number of remaining guesses is decreased.
 Each time the user is asked for a letter, the array containing the “partial solution” word is displayed with * replacing any letters that have not yet been guessed.
 The “scrambled word” word is also displayed each time the user is asked for a letter.
 The user is allowed up to 3 incorrect guesses.
 The game is over when the word is guessed correctly or the three incorrect guesses are used up.
 If the player guesses the word correctly, the player is notified that they have won and the correct word is displayed.
 If the player does not get the correct word and the guesses are all used, the player is notified that they have lost and the correct word is displayed.
 When the game is over, the user should be allowed to play again without having to execute the program again. ( The player will play again with the next set of words in the file)
COP2220 –Scrambled 2
Helpful Hints
 A word is guessed correctly when all of the characters in “word to guess” match the “solution/answer”
 Only letters from a to z and from A to Z will be used.
 Remember that the C language is case sensitive. For this program a = = A. In order to do this you will need to convert all letters to lowercase either before or during the letter matching process. You will need to have a preprocessor directive to include the library file ctype.h in order to access these functions.
o char tolower(char x) – takes the original letter and returns the lowercase equivalent
o char toupper(char x) - takes the original letter and returns the uppercase equivalent
o
 Do NOT assume all input words from the file have lower case letters or that the user will stick to one case
Other Requirements
 You must have meaningful variable and function names.
 You must use consistent and proper indentation
 You must use sufficient comments that tell a programmer what is happening in the program
 You must have at least 8 user-defined functions (not the main function) with meaningful names that perform the specified tasks:
o A function that returns the letter that the user has guessed.
o A function that determines if the player would like to play again.
o A function that tells the user if they won or lost
o A function that sets all of the characters in a word to the same case (upper or lower).
o A function that displays the instructions on how to play the game.
o A function that locates and places the selected letter where it belongs in the partial solution array.
o A function that plays one entire game (not the main function)
o One additional function of your own choice.
 You must use function prototypes placed before the main function and all function definitions must follow the main function.
 All function prototypes and definitions must have a comment describing what the function does. If the function has more than 5 lines of code there should be additional comments.
What to turn in when:
 Outline of program code algorithm as a comment on your code
 Electronic submission of you source code (scrambleUp.c) submitted under the Assignment before the UNIT deadline
COP2220 –Scrambled 3
Sample Output :
Welcome to the Wheel of Scramble game
You will see the word in scrambled form.
Pick a letter and I will show you where the letter belongs in the word.
. . . Next you guess the word . . .
If you can't guess it, don't worry.
You will have three guesses to figure it out!
~~~~~~~~~~~~ PICK A LETTER ~~~~~~~~~~~~~
Here is the scrambled word:
swardpso
Here are the letters you have so far:
********
WHAT LETTER WOULD YOU LIKE TO PLACE? s
------------ GUESS THE WORD -------------
Here is the scrambled word:
swardpso
Here are the letters you have so far:
**ss****
GUESS THE WORD: no
________ no is not the word
________ that was guess number 1
~~~~~~~~~~~~ PICK A LETTER ~~~~~~~~~~~~~
Here is the scrambled word:
swardpso
Here are the letters you have so far:
COP2220 –Scrambled 4
**ss****
WHAT LETTER WOULD YOU LIKE TO PLACE? p
------------ GUESS THE WORD -------------
Here is the scrambled word:
swardpso
Here are the letters you have so far:
p*ss****
GUESS THE WORD: password
The word was password
Yay -- you won :)
Would you like to play again(Y or N)? Y
~~~~~~~~~~~~ PICK A LETTER ~~~~~~~~~~~~~
Here is the scrambled word:
spanhpsie
Here are the letters you have so far:
*********
WHAT LETTER WOULD YOU LIKE TO PLACE? p
------------ GUESS THE WORD -------------
Here is the scrambled word:
spanhpsie
Here are the letters you have so far:
**pp*****
GUESS THE WORD: no
COP2220 –Scrambled 5
________ no is not the word
________ that was guess number 1
~~~~~~~~~~~~ PICK A LETTER ~~~~~~~~~~~~~
Here is the scrambled word:
spanhpsie
Here are the letters you have so far:
**pp*****
WHAT LETTER WOULD YOU LIKE TO PLACE? n
------------ GUESS THE WORD -------------
Here is the scrambled word:
spanhpsie
Here are the letters you have so far:
**pp*n***
GUESS THE WORD: no
________ no is not the word
________ that was guess number 2
~~~~~~~~~~~~ PICK A LETTER ~~~~~~~~~~~~~
Here is the scrambled word:
spanhpsie
Here are the letters you have so far:
**pp*n***
WHAT LETTER WOULD YOU LIKE TO PLACE? s
------------ GUESS THE WORD -------------
COP2220 –Scrambled 6
Here is the scrambled word:
spanhpsie
Here are the letters you have so far:
**pp*n*ss
GUESS THE WORD: hippaness
________ hippaness is not the word
________ that was guess number 3
The word was happiness
Sorry you did not win this round
Would you like to play again(Y or N)? N
Press any key to continue . . .

More products