The game is a word guessing game. The game will randomly select a word, 4 letters in length, and it is the goal of the player to guess that word. If the player guesses correctly, they win. If they guess incorrectly, the game will tell them how many cats and cougars they got. A cat is a letter that is in the random word and was guessed in the correct position. A cougar is a letter in the random word but was in an incorrect position. For example, let’s say our word the player must guess is CAKE. The player guesses ACRE. In this case, they would have 1 cat because the E in ACRE is in the same position as the E in CAKE. The player would also have 2 cougars because of the A and C in ACRE exist in CAKE, but not in the same positions. The user will have 10 attempts to guess the word. If they fail to guess the word after 10 attempts, the game is over.
To start, we will need to create an array of 10 strings, each string must be an isogram and should only be 4 characters in length. An isogram is a word that has no repeating letters. Cake is an example of an isogram because each character is unique in the word. You get to pick the 10 four-letter isograms. Here is a website that will help you find 10 unique four-letter isograms- https://www.morewords.com/unique-letters. Each round in the game is a guess by the player. After each guess, you must output to the player how many cats and cougars they have. If the player guesses correctly, output to them they win and ask if they want to play the game again. If the player does not guess the word in 10 rounds, inform they lose and ask if they wish to play again.
The game should select a random word from the array. The game should also support case-insenstivity when comparing the guessed word with the randomly selected word. Case insensitive means uppercase and lowercase characters should be treated equally. For example, ‘A’ is equal to ‘a’. We will discuss how to randomize an integer value and how to support case-insensitive strings with code examples provided for both (see attached code examples). It is expected that you use functions in this assignment and you should have at least one class to wrap the values for the result indicating the cats and cougars from the resulting guess. Inside the attached zip file is an executable of the game. Play it so you can get a feel for the flow of the game. To make it easier to understand the flow, the word list in the attached game is acre, bear, cake, dear, easy, fame, grit, home, mute, and near.


0 comments