Saturday, May 22, 2010

Help me with a c++ program please?

Hey, I'm supposed to write a c++ program that plays the game hangman.


It's supposed to read in a bunch of words from a file that contains strings, it has to store the strings in an array of strings. Then print out a series of underscores and letters which represent the answer like s__ francis__. The user has to enter a letter, if it's incorrect print out a part of a man on the gallows with dashes and such. If it is correct put it in the word. Also I'm supposed to use 2 functions in the program. The file that the words will be read from will be up to 1000 lines long. And the program has to use strings to store the words not arrays.





Can someone plz explain how to do it or help me get started plz

Help me with a c++ program please?
Break the program into functional pieces.





1. Write a function that reads the file into an array (or one of the std types like vector) of strings.





2. Write a function that draws the man based on how many letters the user has guessed wrong. Return a value if user has lost





3. Write a function the writes out what the guessed right with underscores (pass the word being guessed and the letters guessed). Return if user has won the game with this function





4. Write a function for input from the user.





5. Write a function to return a random word for play from the list of strings.


Loop1


Call 1


Call 5


Loop2


Call 2 if lost print something exit loop2


Call 3 If they have won Print something and exit loop2


Call 4


End loop2


End loop1

umbrella plant

No comments:

Post a Comment