Click here to Skip to main content
15,885,213 members
Articles / Programming Languages / C# 4.0

Hangman Game

Rate me:
Please Sign up or sign in to vote.
4.95/5 (106 votes)
2 Mar 2010CPOL1 min read 226K   13K   109  
A Hangman game as a console application
//|---------------------------------------------------------------|
//|                       HANGMAN GAME                            |
//|         Developed by Yewondwossen Tadesse(Wonde)              |  
//|                                 Version 1.0.0.0               |
//|                                 Copyright ©  2010             |
//|---------------------------------------------------------------|
//|                       HANGMAN GAME                            |
//|---------------------------------------------------------------|
using System;
using System.Collections.Generic;
using System.Text;

namespace Hangman_Game
{
    /// <summary>
    /// Class which holds a collection of words for the hangman game
    /// </summary>
    public class Words : List<Word>
    {
        /// <summary>
        /// Class which holds a collection of words for the hangman game 
        /// </summary>
        public Words()
        {
            this.Add(new Word("COMPLY"));
            this.Add(new Word("THREE"));
            this.Add(new Word("VACATION"));
            this.Add(new Word("INFORMATION"));
            this.Add(new Word("TECHNOLOGY"));
            this.Add(new Word("ORLANDO"));
            this.Add(new Word("COMPUTER"));
            this.Add(new Word("ROUTER"));
            this.Add(new Word("PRINTER"));
            this.Add(new Word("BUDGE"));
            this.Add(new Word("SOFTWARE"));
            this.Add(new Word("HARDWARE"));
            this.Add(new Word("OBJECTIVE"));
            this.Add(new Word("FIlE"));
            this.Add(new Word("EMPLOYEE"));
            this.Add(new Word("SECURITY"));
            this.Add(new Word("DATA"));
            this.Add(new Word("REPORT"));
            this.Add(new Word("PROPERTY"));
            this.Add(new Word("OWNERSHIP"));
        }

        /// <summary>
        /// Pick a random word
        /// </summary>
        /// <returns></returns>
        public Word Pick
        {
            get
            {
                Random RandomPick = new Random();
                int index = (int)(RandomPick.NextDouble() * this.Count);
                Word word = this[index];
                word.Content = word.Content.ToUpper();
                return word;
            }
        }        
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
United States United States
MSCS, MCTS, Senior Software Engineer, Architect, Craftsman, The Ultimate DEV ...
Azure Series


Comments and Discussions