If the user correctly guesses and reveals all of the


Word guessing game: 

Overview: I must create a game in which the user has a set number of tries to correctly guess a word. 

Win condition: If the user correctly guesses and reveals all of the letters, the guessing will end and print "You win" and reveal the word.

Loss condition: The user will only see a "game over" print and be revealed the word.

Required functionality:

  • Main()Should contain the following variables:
  • two arrays of chars. One array named answer to hold a word for the user to guess. the second an exact same sized char array initialized all to the "*" character
  • a constant int for size shared between the two exact same sized arrays called size
  • an int named guesses initialized to double the size of your size variable.
  • an int named revealed initialized to zero.
  • a char named guess initialized to '0'.
  • This should contain the base functionality of the game. A loop should control the game and check if guesses are greater than zero and revealed is less than size.
  • Ask the user for a guess and call check guess.
  • if check guess returns true, let the user know they revealed a letter and call revealLetter().
  • decrement guesses by one as now a turn has been consumed. This must be outside of any conditional logic above^
  • perform a check to see if revealed == size to see if the user revealed all the letters.
  • display() - This function is called anytime the contents of an array needs to be printed on the screen. This should be passed an array, and the size integer.
  • checkGuess() - This is a boolean function that will return true if a match is found in the answer array passed into it. You will need to pass the user's guess to compare, the correct answer array, and the size integer of the array.
  • revealLetter() - This void function should be passed the matching guess char, the answer array, the word array, the size of the arrays (one variable), and REFERENCE to "revealed" so it can be iterated. This function should look through the answer array and find the matching element between the user's guess and the answer array. Copy the answer element data into the word array at that exact position to simulate revealing the letter. Lastly, increment revealed.

Solution Preview :

Prepared by a verified Expert
Business Economics: If the user correctly guesses and reveals all of the
Reference No:- TGS02319881

Now Priced at $30 (50% Discount)

Recommended (99%)

Rated (4.3/5)