Example #1
0
        public void Run(IUiHandler uiHandler)
        {
            bool   presence   = true;
            string randomWord = _wordsRepository.GetRandomWord();

            var anagrams = _wordsRepository.GetAnagrams(randomWord);

            while (presence)
            {
                /*if (anagrams.Count > 1)
                 *  presence = false;
                 * else
                 * anagrams = _wordsRepository.GetAnagrams(randomWord);
                 * uiHandler.WriteMessage(anagrams[1]);*/
            }

            uiHandler.WriteMessage($"\nHere's the word: { randomWord }\nNow insert a word and i'll tell you if it's an anagram");

            string userWord = uiHandler.AskForString("");

            for (int i = 0; i > anagrams.Count; i++)
            {
                if (userWord.Equals(anagrams[i]))
                {
                    uiHandler.WriteMessage($"{anagrams[i]}\n");
                    presence = true;
                }
            }

            if (!presence)
            {
                uiHandler.WriteMessage("Your word is no anagram");
            }
        }
Example #2
0
        public void Run(IUIHandler uiHandler)
        {
            do
            {
                uiHandler.Clear();

                string word = uiHandler.AskForString("Inserisci una parola di cui vuoi conoscere gli anagrammi:");

                var anagrams = _words.GetAnagrams(word);
                uiHandler.WriteMessage("Gli anagrammi trovati sono:");
                foreach (var anagram in anagrams)
                {
                    uiHandler.WriteMessage($"\t{anagram}");
                }
            }while (AnotherMatch(uiHandler));

            uiHandler.WriteMessage("Game over");
        }
Example #3
0
        public void Run(IUiHandler uiHandler)
        {
            string word = uiHandler.AskForString("");

            var anagrams = _wordsRepository.GetAnagrams(word);

            if (anagrams.Count > 1)
            {
                uiHandler.WriteMessage($"I found these anagrams:");
                foreach (var anagram in anagrams)
                {
                    uiHandler.WriteMessage(anagram);
                }
            }
            else
            {
                uiHandler.WriteMessage("\nI didn't find any anagrams");
            }
        }