How michaelkolesidis/hangman works
1. Project shape
- This is a single-process Java terminal game with no web UI, server, database, or network dependencies.
- The architecture is intentionally small and object-oriented: each .java file appears to own one responsibility.
2. Entry point and game coordinator
- Hangman.java is likely the application entry point.
- Game.java is the central orchestrator: it probably owns the main loop, game state, win/lose checks, and coordination between input, word selection, and output.
3. Console presentation layer
- Printer.java is the output boundary to the terminal.
- It likely renders the current hangman figure, masked word, guessed letters, prompts, and end-of-round messages.
- This is the only visible UI layer in the repo.
4. User input boundary
- Input.java appears to be a base abstraction for reading user input from the terminal.
- LetterInput.java and PlayAgain.java likely specialize that boundary for two distinct interactions:
- guessing a letter during play
- deciding whether to restart after a round ends
5. Parsing and validation
- Parser.java and WordParser.java suggest a parsing layer that converts raw text into validated game inputs or normalized words.
- This layer likely keeps malformed console input from reaching the core game logic.
6. Word source and selection
- wordlist.txt is the only external data file and acts as the game's vocabulary source.
- Picker.java, WordPicker.java, and WordParser.java likely form the word-selection path:
- load or parse candidate words from the text file
- pick one secret word for the current round
7. Core in-memory state
- The game state is probably held entirely in memory inside Game.java and related objects.
- Typical state here would be the secret word, guessed letters, remaining attempts, and round status.
- There is no evidence of persistence beyond the static word list.
8. Primary data flow
- Startup: Hangman creates/starts Game.
- Initialization: a word is sourced from wordlist.txt through the picker/parser classes.
- Loop: the player enters guesses via input classes; parsers validate them; game state updates.
- Feedback: Printer renders the updated state after each guess.
- Termination: the game ends on win/lose, then PlayAgain may trigger a new round.
9. Subsystem boundaries
- UI boundary: Printer
- Input boundary: Input, LetterInput, PlayAgain
- Data boundary: wordlist.txt
- Game orchestration: Game, Hangman
- Selection/parsing utilities: Parser, WordParser, Picker, WordPicker
10. Deployment/runtime characteristics
- The only required runtime is the Java JVM.
- The app is likely run directly from the command line and depends on relative access to wordlist.txt.
11. Diagram takeaway
- If you draw this architecture, it should look like a thin CLI shell around a core game loop, with terminal input/output at the edges and a local text file as the only external data source.
Main entry points: Game.java Game · WordPicker.java WordPicker · LetterInput.java LetterInput · PlayAgain.java PlayAgain
Components 11
CLI Runtime
Entry point, game loop, terminal I/O
- Hangman · Starts the application
Hangman.java - Game · Runs rounds and owns game state
Game.java - Printer · Renders game state and prompts
Printer.java - Input · Base console input abstraction
Input.java - LetterInput · Reads and validates letter guesses
LetterInput.java - PlayAgain · Handles round restart choice
PlayAgain.java
Word Pipeline
Parsing and selecting secret words
- Parser · General text parsing and validation
Parser.java - WordParser · Normalizes candidate words
WordParser.java - Picker · Base word selection abstraction
Picker.java - WordPicker · Chooses the secret word for a round
WordPicker.java - wordlist.txt · Vocabulary file used by the picker
wordlist.txt
Connections 13
- Hangman → Game: launches · Application entry creates the game loop
- Game → Printer: renders · Game sends state and prompts to the terminal
- Game → LetterInput: requests guess · Game asks for the next letter guess
- Game → PlayAgain: requests replay · Game asks whether to start another round
- Game → WordPicker: gets word · Game obtains a secret word for each round
- LetterInput → Input: extends · Specialized console input
- PlayAgain → Input: extends · Specialized console input
- LetterInput → Parser: validates · Letter input is parsed and checked
- PlayAgain → Parser: parses · Replay choice is parsed and checked
- WordPicker → Picker: uses · WordPicker builds on selection logic
- WordPicker → WordParser: normalizes · Candidate words are parsed before selection
- WordPicker → wordlist.txt: reads · Secret words come from the text file
- WordParser → Parser: builds on · Word-specific parsing reuses generic parsing