Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

C#beginnercliAI generated

Console Hangman with Word Bank Files

Build the classic Hangman word game for the console in C#: the player chooses a category (such as animals, countries or food) and a difficulty, then guesses letters to reveal a hidden word before the hangman drawing is complete. Words come from text files, one per category, so new word lists can be added without changing the code, and the difficulty controls word length and the number of allowed mistakes. The game keeps score across rounds. It's a fun first C# project: you'll learn reading files, strings and characters, collections such as HashSet, loops and conditions, console input and output, and organizing code into small classes you can test.

Estimate
~6.5h
Steps
6
Completed by
0
Proposed by
codeseed.app

.NET CLI

Project roadmap

  1. 01

    Load the word banks

    ~1h

    Create a project with dotnet new console and a words folder with a text file per category (at least 30 words each). Read all categories at startup with File.ReadAllLines, trimming, uppercasing and skipping empty lines and words with characters other than letters. Let the player choose a category and a difficulty (easy: 4 to 6 letters and 8 mistakes; medium: 6 to 8 letters and 7; hard: 8 or more letters and 6). Show an error when the words folder is missing. Done when: a random word of the right length is chosen from the chosen category.

  2. 02

    Track the guesses

    ~1.5h

    Write a HangmanGame class holding the secret word, a HashSet of guessed letters and the number of mistakes left, with a method Guess(char) that returns whether the letter was new, correct or wrong, and a property showing the word with unguessed letters as underscores (C _ T). Reject non-letters and repeated guesses without counting them as mistakes. Done when: unit-style checks show the revealed word and mistakes update correctly.

  3. 03

    Draw the hangman

    ~1h

    Store the hangman drawing as ASCII art stages (from the empty gallows to the complete figure) and show the stage matching the number of mistakes made, scaled to the difficulty's allowed mistakes. Show the word, the letters guessed so far and mistakes left after each guess, clearing the console between turns. Done when: the drawing grows with each wrong guess.

  4. 04

    Handle winning and losing

    ~1h

    End the round when every letter is revealed (a win) or no mistakes are left (a loss, revealing the word), showing an end screen, then ask whether to play again. Done when: both endings work, and a new round starts with a new word.

  5. 05

    Keep score

    ~1h

    Track wins, losses and the current winning streak across rounds in the session, shown on the end screen, and the best streak saved to a small file so it's kept between sessions. Done when: the score and streaks are shown correctly, and the best streak survives restarting the game.

  6. 06

    Test it

    ~1h

    Create an xUnit test project and test the HangmanGame class: correct and wrong guesses, repeated guesses, invalid characters, winning, losing, and word loading with a temporary folder. Done when: dotnet test passes.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~6.5h · 6 steps

Tech stack

.NET CLI