Description
Objective:
The objective of this programming assignment is to create a professional-grade Hangman game in Python. This assignment will challenge students to apply their Python programming skills, including string manipulation, loops, and conditional statements, to build an interactive and enjoyable game.
Requirements:
Game Logic:
Implement the classic Hangman game where a player must guess a word letter by letter.
- Choose a word from a predefined list (you can create your own list or use an external word list).
Display the word as underscores and reveal correctly guessed letters.
- User Interaction:
- Create a user-friendly command-line interface (CLI) for the game.
- Display the current state of the hangman and the progress of the word.
- Allow the player to input a single letter guess for each turn.
Handle invalid inputs gracefully (e.g., non-letter characters, duplicate guesses).
- Gameplay:
- Define the rules of the game, including the number of allowed incorrect guesses before the player loses.
- Keep track of the player’s guesses and update the hangman state accordingly.
- End the game when the player wins by guessing the word or loses by running out of guesses.
- Word Lists:
You can use your creativity to prepare a list of words for the game. Ensure that the words are suitable for players of all ages.
- Include a mechanism to randomly select a word from the list for each game.
- Scoring:
- Implement a scoring system that rewards the player for guessing the word correctly within a certain number of attempts.
- Display the player’s score at the end of each game.
Error Handling: Implement error handling to ensure that the game gracefully handles invalid input and exceptional cases.
- Documentation: Provide clear and concise documentation for your code, explaining each module, class, and function’s purpose. Include instructions on how to run the game.
- Testing: Create a set of test cases to verify that the game logic works correctly under various scenarios. Include a testing section in your documentation.