示例#1
0
        void Start()
        {
            // Choose a word
            List <string> potentialWords = ReadWords();
            string        gameWord       = SelectWord(potentialWords);

            // Init the game
            HangmanGame hangman = new HangmanGame();

            hangman.Init(gameWord);
            DisplayWord(hangman.guessedWord);
            bool playing = PlayHangman(hangman);

            // Evaluate if the player won or lost the game
            if (playing)
            {
                Console.WriteLine("You guessed the word!");
            }
            else
            {
                Console.WriteLine("You didn't guess the word...");
            }

            Console.ReadKey();
        }
        void Start()
        {
            List <string> words = new List <string>();

            words = ListOfWords("words.txt");
            HangmanGame hangman = new HangmanGame();

            hangman.Init(SelectWord(words));
            //this is to see if the words are being displayed.
            //Console.WriteLine("the secret word is: " + hangman.secretWord);
            //Console.WriteLine("the guessed word is: " + hangman.guessedWord);
            if (PlayHangman(hangman))
            {
                Console.WriteLine("You guessed the word!!");
            }
            else
            {
                Console.WriteLine("You run out of attempts");
            }
        }