A feature-rich command-line Hangman game written in Java. It uses SQLite for persistent storage, JSON for word categories, and follows Semantic Versioning with GitHub Actions for automated testing and releases.
This CLI game challenges users to guess words across various categories and difficulties. It includes:
- Scoring and point mechanics
- Persistent user accounts
- Hints using point currency
- Top 5 leaderboard system
- Word categories from JSON
- 🎯 Word selection by category and difficulty
- 💰 Points system for hints
- 🏆 Scores awarded only for wins
- 📊 Persistent data in SQLite
- 🔁 User management (create/load/delete/view)
- 🧠 Hint types: reveal letter, extra attempt, reveal fact
- 🧪 Unit tested using JUnit & Mockito
- 📦 JSON-based word list (with descriptions and hints)
Purpose | Technology |
---|---|
Language | Java 17+ |
Database | SQLite (via JDBC) |
Word Storage | JSON (words.json) |
Input Handling | Scanner (CLI) |
Testing | JUnit + Mockito |
CI/CD | GitHub Actions |
Versioning | Semantic Versioning |
Main.java
|
v
Hangman.java
├── GameState enum
├── UserSession (manages users)
├── WordManager (loads JSON, selects words)
└── GameSession (executes game loop)
├── Uses HintSystem, InputHandler, DisplayManager
└── Updates Score & Points via SQLite
Action | Points | Scores |
---|---|---|
Correct guess | +1 to +3 | — |
Complete word (win) | — | +total points |
Use hint | −3 to −5 | — |
Lose round | 0 | 0 |
- Points = Currency for hints, carried between games
- Scores = Only earned when winning; used for leaderboard
Hint | Cost (Points) |
---|---|
Reveal a letter | 5 |
Reveal fact about word | 3 |
Add extra guess | 4 |
Sample words.json
:
{
"Animals": {
"description": "Creatures in the animal kingdom",
"easy": [
{ "word": "cat", "hint": "Purrs and meows" }
],
"medium": [
{ "word": "giraffe", "hint": "Tallest land animal" }
]
}
}
- Java 17+
- Maven
mvn compile exec:java -Dexec.mainClass="com.example.Main"
mvn test
- Start from a CLI main menu.
- Create or load a user.
- Pick a category and difficulty.
- Play by guessing letters.
- Use hints (points are deducted).
- Win to earn score and leaderboard rank.
- SQLite stores:
players
(user info)scores
(per game)points
(hint currency)
Top 5
users by highest score shown at any time
- Multiplayer mode (via sockets or REST)
- Daily challenge words
- Game streaks and badges
- Visual frontend (JavaFX or web)
- Export/import word sets
# Fork, then:
git checkout -b feat/my-feature
git commit -m "Add new feature"
git push origin feat/my-feature
# Open a pull request
This project is licensed under the MIT License.