-
Notifications
You must be signed in to change notification settings - Fork 27
Labels
GamesAssociated with Games projectAssociated with Games projectenhancementNew feature or requestNew feature or request
Description
User Story
As a player, I want to play a conventional game of Hangman with the product, so that I can enjoy the word-puzzle-solving experience of a familiar game.
Acceptance Criteria
- The Hangman game allows the player guess a secret word the game has chosen.
- Each player guess may be a single letter or the entire word.
- For each incorrect guess, a part of a hangman figure is drawn (head, body, arms, legs), indicating the number of guesses used up.
- The game ends when the word is correctly guessed (player wins) or the hangman drawing is completed (player loses).
Notes / Design Ideas
Consider the following initial simplifications and extensions:
Words
- Random word chosen from a hardcoded list
- (Extension) Hardcoded list replaced by loading word list from a file
- Only alphabetic characters
- Case-insensitive
Gameplay
- 6 incorrect guesses (tries) allowed
- (Extension) Parameterized with customization of hangman diagram
- User can guess a letter or a full word
- Incorrect full word guesses cost one try
- Repeated guesses are not penalized
User Interface
- Command-Line Interface (scanner-based OK)
- Current word progress is shown using dashes for not-yet-guessed letters (initially all dashes)
- After each guess:
- ASCII hangman diagram is shown
- Letters already guessed are shown
- Current word progress is shown
Scoring
- If the player wins, the score equals the number of remaining tries
- If the player loses, the score is zero (0)
play()returnsOptional.of(score)
Testability
Consider providing for injection of an InputStream to facilitate testing. For example, include a no-parameter constructor public HangmanGame() that invokes a parameterized constructor public HangmanGame(InputSream)
Consider adding testing helper methods that are either protected or package-private. For example,
- a method that returns the set of guessed letters (such as by a
Set<Character>)) - a method that returns the current number of remaining tries (an
int) - a method that returns whether or not the word is fully guessed (a
boolean) - a method that sets the secret word
Some examples of test methods:
- Simulate winning a game where the user guesses letters and wins.
- Simulate a winning game by a full word guess.
- Simulate a losing game after 6 incorrect guesses.
- Simulate repeated letter guesses to ensure they don't reduce remaining tries
- Simulate invalid input (non-alphabetic) and ensure it is igrnored
Sub-issues
Metadata
Metadata
Assignees
Labels
GamesAssociated with Games projectAssociated with Games projectenhancementNew feature or requestNew feature or request
Type
Projects
Status
Backlog