Question: **Construct a flowchart utilizing C++ language for thefollowing project*** THE PROBLEM : Everyone has played the classic word guessing game hangman. Yourjob is to create

**Construct a flowchart utilizing C++ language for thefollowing project***

THE PROBLEM:

Everyone has played the classic word guessing game hangman. Yourjob is to create a program that will allow a user to play thegame.

To start things out, create a text file named "puzzles.txt" thatwill contain puzzles, one per line, of words with no spaces, usinguppercase letters. There should be no more than 100 puzzles in yourfile (make sure you have no fewer than 20). Each puzzle will be oneword. It might look something like this:

DONKEY

HOORAY

JENKINS

BASKETBALL

YIPPEE

RAY

PROGRAMMING

After the program reads the puzzles from the file, it willrandomly choose one for the user to guess. The underscore character_ will be used to indicate a letter that needs to be guessed. Forexample, if the word was 6 characters long, the initial user screenshould look something like this:

_ _ _ _ _ _ _

Available: ABCDEFGHIJKLMNOPQRSTUVWXYZ

Guess:

For this project, main() driver function is provided. It willmake calls to 4 functions. The requirements for each of thesefunctions is also provided. Your job will be to write the code forthese functions, as well as document/comment the entireprogram.

FUNCTIONS:

1. readPuzzles – twoarguments: string array of words,integer wordCount (referenceparameter)

  • Returns nothing
  • This function opens up the puzzles file, verifies it openssuccessfully, reads the puzzles from the file into the arrayof words, updatesthe wordCount to reflect howmany puzzles were read.

2. displayPuzzle – twoarguments: string word, array ofbool guessed

  • Returns nothing
  • This function loops through each of the letters ofthe word, looking at thecorresponding position ofthe guessed array. If theletter has been guessed, display it. If not, display theunderscore. Also, display a space between each letter, as well as acouple of end lines after the word. It might output something likethis:

_ A S K __ B A _ _

3. found – three arguments:string word, array ofbool guessed,character guess

  • This functions returns a bool, true ifletter guess is found inpuzzle word, otherwise false
  • If the guess is inthe word, the function should alsochange the guessed array totrue at each position it exists

4. winner – two arguments:array of bool guessed, the integernumber of letters in thepuzzle

  • This function will loop through all of the elements ofthe guessed array. If anyelement is false, the function should return false. If all of theelements are true, the function should return true.

You must include proper comments / documentation for the mainfunction, as well as the 4 functions that you write.

The main driver: /*You will need to define these constants as you

The main driver: /*You will need to define these constants as you see fit and as appropriate //Change these?? to a value const int MAX_WORDS = ??; const int MAX_WORD_SIZE = ??; const int MAX GUESSES = ??; const int NUM_LETTERS = ??; int main() { string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string words [MAX_WORDS]; int wordNum=0, letters-0, misses=0, numWords=0; char guess; bool quessed [MAX_WORD_SIZE]; readPuzzles (words, numWords); grand (time (0)); WordNum=rand() % numWords; wwwwwww letters = words [wordNum].length(); for (int i=0; i > guess; guess toupper (guess); for (int i=0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!