Some of you may be wondering why I created this post. In short, I want to challenge you.
Today I woke up randomly at 6:00 am (super early for me) and had the idea to post this challenge online to challenge others. The Hangman problem itself was a Final Project assignment in my C++ Fundamentals class last semester. And yes, I did complete it.
So now I'm passing on the challenge.
Today I woke up randomly at 6:00 am (super early for me) and had the idea to post this challenge online to challenge others. The Hangman problem itself was a Final Project assignment in my C++ Fundamentals class last semester. And yes, I did complete it.
Have you learned C++ Fundamentals yet? If so, here's a challenge to test your knowledge!
Please note: This challenge is a learning experience for you. So looking up solutions online is allowed, but you should try to program it yourself before looking up how to do it. A certain level of struggling is necessary to understand and learn from your mistakes.
If you need help, I strongly recommend asking your questions here: http://www.cplusplus.com/
Create an account and ask on the forums. People there are super friendly, helpful, and will explain the solution too (as long as your question is polite and detailed)! This is an alternative to Stack Exchange, which may be a hostile environment for beginners / learners. If you think otherwise, don't bother mentioning it. I'm not going to debate whether Stack Exchange is "good" or "bad". It's a waste of time.
Create an account and ask on the forums. People there are super friendly, helpful, and will explain the solution too (as long as your question is polite and detailed)! This is an alternative to Stack Exchange, which may be a hostile environment for beginners / learners. If you think otherwise, don't bother mentioning it. I'm not going to debate whether Stack Exchange is "good" or "bad". It's a waste of time.
You may post your solutions if you so choose, however, that is not required. It may help other people that are stuck though so I encourage you to! Just be sure to paste any code into Pastebin INSTEAD of directly on the post to avoid users accidentally seeing answers before they've had the chance of challenging themselves.
Problem To Solve:
Create a Hangman game with these instructions:
1. Create a text file called words.txt and include at least 20 English dictionary-based words.
2. The program will read the list of words from the file into an array like data structure.
3. Program chooses a random word from the array and starts asking the player to guess the word one character at a time until the player wins or runs out of predefined number of tries.
4. Game continues until the player wants to quit.
5. Add a check to make sure the user does not enter a previously guessed letter. For example, if the user inputs "a" then inputs "a" later on, it will tell them they cannot input that letter again.
5. Include as many "bells and whistles" as possible to make the game entertaining and intuitive to play.
Be sure to provide programmer username, program name, and program information in the comments at the top. Additionally, provide your algorithm steps (how you go about solving it, in order).
As always, use good programming practices such as:
- closing opened files after using them
- using self explanatory variable names
- not using "using namespace std;" (however, this is only a recommendation and not required for this program)
- providing useful comments throughout your code to explain what is going on
If you don't know what Hangman is, check here.
If you successfully completed this challenge, I recommend trying to complete tic-tac-toe using multidimensional array(s).
Create a Hangman game with these instructions:
1. Create a text file called words.txt and include at least 20 English dictionary-based words.
2. The program will read the list of words from the file into an array like data structure.
3. Program chooses a random word from the array and starts asking the player to guess the word one character at a time until the player wins or runs out of predefined number of tries.
4. Game continues until the player wants to quit.
5. Add a check to make sure the user does not enter a previously guessed letter. For example, if the user inputs "a" then inputs "a" later on, it will tell them they cannot input that letter again.
5. Include as many "bells and whistles" as possible to make the game entertaining and intuitive to play.
Be sure to provide programmer username, program name, and program information in the comments at the top. Additionally, provide your algorithm steps (how you go about solving it, in order).
As always, use good programming practices such as:
- closing opened files after using them
- using self explanatory variable names
- not using "using namespace std;" (however, this is only a recommendation and not required for this program)
- providing useful comments throughout your code to explain what is going on
If you don't know what Hangman is, check here.
If you successfully completed this challenge, I recommend trying to complete tic-tac-toe using multidimensional array(s).
Do NOT try to complete this problem until you have done the first problem and completed your own Hangman game. If you try to complete this one first, you may be making it easier and ruin the challenge for yourself because it provides a solution to the Hangman problem.
Hangman Game Code:
Main File:
Header Files:
-
-
There is a bug that occasionally happens when playing this game. Figure out the problem and solve it. If you decide to post your solution, be sure it is an a spoiler so others may be given the chance as well.
Bug: Sometimes when you input a letter that you have NOT inputted before, it will say that you have. This includes (but is not limited to) letters that are required to solve the word. If you input that letter again, then it will work. So if this bug occurs, it is still possible to win by inputting the letter again.
It may take a few times of playing to encounter this bug.
Note: This is my code. I am posting this to allow you to challenge yourself, I have already completed the program and turned it in for my class.
Bug: Sometimes when you input a letter that you have NOT inputted before, it will say that you have. This includes (but is not limited to) letters that are required to solve the word. If you input that letter again, then it will work. So if this bug occurs, it is still possible to win by inputting the letter again.
It may take a few times of playing to encounter this bug.
Note: This is my code. I am posting this to allow you to challenge yourself, I have already completed the program and turned it in for my class.
Hangman Game Code:
Main File:
Header Files:
-
-
As stated previously, it is up to you whether you decide to post your solutions here. It may help others, however, be sure to copy and paste ALL code into pastebin or some other site. Do NOT provide the code directly on the forum as it will spoil answers for other people that haven't tried to solve it yet.
This challenge is for fun and learning. If you don't like it or think it's dumb for whatever reason, you don't have to do it. Just move along instead of providing negative and unnecessary comments.
