#Task
Everyone has played the classic word guessing game hangman. Your job is to create a program that will allow a user to play the game.
#Functionality
The program will obtain a random word from the list of 20 words within the text file
It will then show an output of the following which allows the user to play and guess the word that was randomly selected
It makes calls to 4 functions. The requirements for each of these functions is also provided. Your job will be to write the code for these functions, as well as document/comment the entire program. FUNCTIONS:
- readPuzzles – two arguments: string array of words, integer wordCount (reference parameter) Returns nothing This function opens up the puzzles file, verifies it opens successfully, reads the puzzles from the file into the array of words, updates the wordCount to reflect how many puzzles were read.
- displayPuzzle – two arguments: string word, array of bool guessed Returns nothing This function loops through each of the letters of the word, looking at the corresponding position of the guessed array. If the letter has been guessed, display it. If not, display the underscore. Also, display a space between each letter, as well as a couple of end lines after the word. It might output something like this: _ A S K _ _ B A _ _
- found – three arguments: string word, array of bool guessed, character guess This functions returns a bool, true if letter guess is found in puzzle word, otherwise false If the guess is in the word, the function should also change the guessed array to true at each position it exists
- winner – two arguments: array of bool guessed, the integer number of letters in the puzzle This function will loop through all of the elements of the guessed array. If any element is false, the function should return false. If all of the elements are true, the function should return true