Ejemplo n.º 1
0
        void playLingo(LingoGame game)
        {
            int  attempts = 0;
            bool hasWon   = false;

            while (attempts < 5 && !hasWon)
            {
                attempts++;

                string guessWord = input.readString(
                    $"Geef een 5 letter woord (poging {attempts}): ",
                    "Het moet een woord zijn bestaande uit 5 letters",
                    input => input.Length == 5
                    );

                PositionState[] characterStates = game.evaluateGuess(guessWord);
                showGuessResults(characterStates: characterStates, guessWord: guessWord);

                if (game.isCorrectWord(guessWord: guessWord))
                {
                    hasWon = true;
                }

                Console.WriteLine();
            }

            if (hasWon)
            {
                Console.WriteLine($"Gefeliciteerd! Het woord was inderdaad {game.secretWord}");
            }
            else
            {
                Console.WriteLine($"Helaas. Het woord was {game.secretWord}");
            }
        }
Ejemplo n.º 2
0
        void start()
        {
            List <string> wordList   = readWords();
            string        secretWord = randomWord(wordList: wordList);

            LingoGame game = new LingoGame();

            game.setSecretWord(word: secretWord);

            playLingo(game: game);

            Console.ReadKey();
        }