https://academic-tutors.net/wp-content/uploads/2020/04/logo-300x60.png 0 0 Paul https://academic-tutors.net/wp-content/uploads/2020/04/logo-300x60.png Paul2021-09-05 11:51:422021-09-05 11:51:42assignment specifications you must implement simplified version hangman our simplified versi
Assignment Specifications You must implement a simplified version of hangman. In our simplified version, the player gets 7 incorrect guesses to guess all of the characters within a phrase. You are required to implement the specified functions and utilize any provided functions. Hangman Algorithm ● Get phrase to be solved (using getline to allow for spaces in the phrase to be guessed) ● Clear output window so phrase is not seen (clear window using clearScreen()) ● Setup unsolved phrase so game has another string with dashes in place of characters (call setupUnsolved function) ● Output the unsolved phrase ● Play Game until phrase is completely guessed or no wrong guesses left, 7 wrong allowed ○ Get letter guess (call getGuess function) (All user input & respective prompts after initial phrase should ONLY occur in the getGuess function) ○ Update string containing all characters guessed so far ○ Take action on the guess ■ Correct: update unsolved phrase using the updateUnsolved function ■ Incorrect: update the wrong guess count ○ Clear the screen, using clearScreen() ○ Output game status ■ updated unsolved phrase – phrase with dashes for unguessed letters ■ list of characters guessed so far ■ number of wrong guesses left ● Output game over message (You lost! or Congratulations!!) Header File We have supplied a header file to be utilized with this assignment. The file name is assn.h. In the file is a function that will clear the terminal window. You will call this function to clear the screen in the specified spots within the algorithm. You should include the header file at the top of your assignment with the other includes (this one should be last): #include “assn.h” Additional Requirements and Hints ● Implement each function and get feedback/credit for each before doing main game ● All user input statements should be followed by an output statement to create a blank line. ● All inputs and corresponding prompts after initial phrase occur only in body of getGuess ● All phrases and valid guesses will use lowercase alphabetic characters ● The player gets 7 wrong guesses. ● No input or output statements exist in setupUnsolved or updateUnsolved ● You should be utilizing a single puzzle variable and assigning into it the return value from setupUnsolved and updateUnsolved. ● Use at(): This member function can go on either side of an ‘=’ sign. To either get and use the value at a specified position (right side) or to assign a new value into that specific position (left side). at() throws an exception when you access an invalid value, this will save you time hunting down bugs. Do not use  syntax as it may or may not throw an error. ● bool isalpha(char): In order to check to see if a guess is proper alphabetic character you can use this built in function that takes a single character as an argument. ● Note: The functions setupUnsolved and updateUnsolved act in opposition to each other. This means that should have slight logical differences but are coded similarly. Functions The following 3 functions are required. You must define, implement and correctly use these 3 functions with the exact specifications described below. In fact, just copy-and-paste these comments and function headers into your source file one-by-one as you implement them. /// @brief Puts dashes in place of alphabetic characters in the phrase. /// @param phrase the phrase to be solved /// @return the phrase with all alphabetic characters converted to dashes string setupUnsolved(string phrase) /// @brief Replaces the dashes with the guessed character. /// @param phrase the phrase to be solved /// @param unsolved the phrase with dashes for all unsolved characters /// @param guess the char containing the current guessed character /// @return the new unsolved string with dashes replaced by new guess string updateUnsolved(string phrase, string unsolved, char guess) /// @brief Gets valid guess as input. /// /// A guess is taken as input as a character. It is valid if /// 1) it is an alphabetic character and /// 2) the character has not already been guessed /// /// @param prevGuesses the string containing all characters guessed so far /// @return a valid guess and only a valid guess as a character char getGuess(string prevGuesses) Reading diff Output Due to the possibility of an excess amount of output we simply show the differences between the solution’s output and the output of the program that is being tested; whether it is output specific to a function or the whole program’s output. The following explains how to read this difference output. — hangman.cpp +++ solution.cpp @@ -56,2 +56,2 @@ wrong guesses left: 0 -you lost +you lost! The first 2 lines are a key, they show the symbol associated with with the listed file. The lines after the @@ sybmols show differences. The first character in every line states which file it comes from. If no symbol character (“+” or “-”) is shown then it occurs in both files. In order to fix your output you should change all lines that do not match the solution. Specific to the above: The – symbol is associated with the file named hangman.cpp The + symbol is associated with the file named solution.cpp The line “wrong guesses left” has no initial symbol, it occurs in both files. The line “-you lost” has a minus sign as an initial symbol, it occurs in hangman.cpp. The line “+you lost” has a plus sign as an initial symbol, it occurs in solution.cpp. To fix the above example, the hangman.cpp is missing an exclamation mark; if we add it then the output will match and this specific case will disappear. Example Run (user input has been bolded and underlined for emphasis, c by itself is clearScreen output) Enter phrase: hello. c Phrase: —–. Enter a guess: h c Phrase: h—-. Guessed so far: h Wrong guesses left: 7 Enter a guess: e c Phrase: he—. Guessed so far: he Wrong guesses left: 7 Enter a guess: l c Phrase: hell-. Guessed so far: hel Wrong guesses left: 7 Enter a guess: d c Phrase: hell-. Guessed so far: held Wrong guesses left: 6 Enter a guess: l Invalid guess! Please re-enter a guess: 8 Invalid guess! Please re-enter a guess: o c Phrase: hello. Guessed so far: heldo Wrong guesses left: 6 Congratulations!!