You haven't failed. You just haven't gotten to the answer yet. I don't think the project is necessarily beyond what you've learned so far. If you have categories, then each category contains an array of words. If the number of words is up to 7, then each category must also keep track of how many words it actually has. If you know how to generate a random number, then you can use that as an index into an array to pick the corresponding word. I don't think it matters how long any one word is: from that point the program is the same, the user guesses whether a letter is present until all letters are accounted for. Don't forget that if a letter appears more than once in a word (for example the 'n' or 'o' in London), if the user guesses that letter, you need to show all occurrences at the same time.
Start: _ _ _ _ _ _
User guesses 'o': _ o _ _ o _
User guesses 'd': _ o _ d o _
And so on.
So, you need to keep track of (1) the original word, (2) which correct letters the user has tried, and what partial word to display, (3) which incorrect letters the user has tried, and how many (the user loses if too many wrong guesses), and (4) whether the word is finished (and the user has won).
Start simple and work up. Start by making your categories, and word lists for each, and printing them out. Then modify your program to prompt the user for a category, and print out only those words. Then modify it to generate a random number and print out only that word. Then you can start on the actual game-play. Also, don't be afraid to put lots of meaningful debug output in your program, telling you where it is in the code, and what it's doing. It's easy enough to remove all that once it works perfectly for you!
raptr_dflo
Practically a Master Poster
605 posts since Aug 2010
Reputation Points: 76
Solved Threads: 83
Skill Endorsements: 1
Question Answered as of 1 Year Ago by
raptr_dflo