Example #1
0
        private void Play()
        {
            IWordsRepository repo  = new WordsRepository(new FileDictionaryLoader());
            List <IGameplay> games = new List <IGameplay>
            {
                new Training(repo),
                new Match(repo)
            };

            IGameplay game = ChooseGame(games);

            game.Run(this);
        }
Example #2
0
        public override void Run(WordsRepository repository)
        {
            string        word;
            List <string> anagrams;

            UiHandler.WriteMessage(Description);
            UiHandler.WriteMessage();
            UiHandler.WriteMessage("Please type a word to anagram");

            word = UiHandler.InsertWord();

            anagrams = repository.ProduceAnagrams(word);

            if (anagrams.Count() > 0)
            {
                if (anagrams.Count() == 1)
                {
                    UiHandler.WriteMessage("The provided word does not have any anagram...");
                }
                else
                {
                    foreach (string w in anagrams)
                    {
                        if (!word.Equals(w))
                        {
                            UiHandler.WriteMessage(w);
                        }
                    }
                }
            }
            else
            {
                UiHandler.WriteMessage("Sorry, the chosen word does not exist in the word repository...");
            }

            UiHandler.WriteMessage();
            UiHandler.WriteMessage();
        }
Example #3
0
 public abstract void Run(WordsRepository repository);