This exercise focuses on stepwise refinement to implement Multi-Hangman, a variation of the classic Hangman game. Players guess multiple words simultaneously, with each word having its own life counter. The game ends when either all words are solved (win) or one word is lost (lose).
- Multiple Words: The player chooses how many words they want to guess.
- Lives System: Each word starts with 4 lives, and incorrect guesses reduce the remaining lives.
- Custom Input: Players input words and guesses. Words are automatically converted to uppercase.
- Game End Conditions:
- Win: All words are guessed correctly.
- Lose: At least one word runs out of lives.
src/
In.javaHelper class for inputOut.javaHelper class for outputHangman.javaClass representing the logic for a single Hangman wordMultiHangman.javaMain class managing multiple Hangman gamesHangmanApp.javaEntry point for the Multi-Hangman game
tests/
Testprotokolle.txtTest case and results for a complete game session
-
Stepwise Refinement:
- Start by defining the overall structure of the game.
- Decompose the problem into smaller subproblems (e.g., managing lives, checking guesses).
- Use helper methods to handle repetitive tasks, like displaying words or checking game status.
-
Game Logic Highlights:
- Display words with unrevealed letters as
.and guessed letters as their actual value. - Include visual feedback for remaining lives using the
printHanger(int lives)method.
- Display words with unrevealed letters as
-
Test Cases:
- Valid inputs (e.g., correct guesses, valid word selections).
- Invalid inputs (e.g., selecting a non-existing word, entering invalid characters).
-
Setup the Game:
- The player starts by entering how many games (words) they want to play.
- For each game, the player inputs a word to guess. Example:
How many Hangman do you want to play? 2 Type the Word for game #0 > bun Type the Word for game #1 > bird
-
Guess Letters:
- Each round, the player is prompted to guess a letter and choose which word (number) to play. Example:
Which letter do you want to guess? b Which word (number) do you want to play? 1
- Each round, the player is prompted to guess a letter and choose which word (number) to play. Example:
-
Feedback on Guesses:
- Correct Guess: The guessed letter is revealed in the word.
- Incorrect Guess: One life is lost for that word, and the hangman figure progresses.
-
Game Over Conditions:
- Win: The player guesses all letters for every word.
- Lose: A wordโs lives reach zero, and the game reveals the word.
-
Game States:
- Players are informed about their progress, including guessed letters, remaining lives, and hangman visuals for each word.
-
Special Scenarios:
- Duplicate Guesses: If a letter is guessed again, the player is reminded that it was already guessed.
- Completed Words: If the word is already won or lost, the game skips further interaction with it.
- Programming Language: Java
- Editor: Visual Studio Code with JavaWiz extension
This project is licensed under the MIT License.