Problem statement
Design the object model and core APIs for a single-process word-guessing game engine (think a classic hangman round played in a terminal or as a test harness). A secret word is chosen, the player calls out one letter at a time, and each guess either reveals every matching position in the word or costs one of a fixed budget of wrong attempts. The engine owns the rules and the running state; whatever drives it merely feeds letters in and reads the masked word, the score, and the outcome back.
Operating context. One round at a time, one player, one thread, no clock and no network. At construction the engine is handed a word source (which supplies the secret word) and the number of wrong attempts allowed. A guess is a single letter and is case-insensitive. A letter already guessed (whether it hit or missed) is a repeat and must not cost a second attempt. A correct guess reveals the letter at every position it occurs; a wrong guess decrements the remaining attempts. The round ends in a win when every position is revealed, or in a loss when the remaining attempts reach zero. Scoring rewards efficient play: fewer wrong guesses and fewer total guesses score higher.
Out of scope. Any rendering or drawing of the gallows/figure, console or keyboard input parsing, multiplayer or networked play, persistence of scores or resume across rounds, and hint or reveal-a-letter power-ups. Design only the in-process rules engine and its object model.
What to produce. The class hierarchy (entities such as Game/Round and any value objects like a Letter, a Guess, or the masked-word view), the public API each class exposes, and the state transitions of the round (setup, in-progress, won, lost) and of a guess (hit, miss, repeat). Be explicit about: how the word source is abstracted so a test can force a known word; how the masked reveal is computed without leaking un-guessed letters; how repeats are detected so they never cost an attempt; how game-over (win vs loss) is decided after each guess; and how the scoring rule is kept swappable.
Must do 6
Functional requirements
- Accept a single-letter guess, normalize its case, and classify it as a hit, a miss, or a repeat of an earlier guess.