Example #1
0
        /// <summary>
        /// Metoda dodająca słowo do słownika przy pomocy Buildera
        /// </summary>
        /// <param name="pol">Słowo polskie</param>
        /// <param name="ang">Słowo angielskie</param>
        public void addWord(String pol, String ang)
        {
            var director = new Director();
            var builder  = new WordBuilder();

            director.Builder = builder;

            director.buildWord(pol, ang);
            wordList.Add(builder.GetWord());
        }
Example #2
0
        /// <summary>
        /// Metoda tworząca instancję słownika (jeśli jeszcze nie istnieje)
        /// </summary>
        /// <returns>Zwraca instancję słownika</returns>
        public static Dictionary getInstance()
        {
            if (_instance == null)
            {
                _instance = new Dictionary();
                string[] words;
                String   line;
                System.IO.StreamReader file = new System.IO.StreamReader("dic.txt");
                while ((line = file.ReadLine()) != null)
                {
                    words = line.Split(' ');
                    var director = new Director();
                    var builder  = new WordBuilder();
                    director.Builder = builder;

                    director.buildWord(words[0], words[1]);
                    wordList.Add(builder.GetWord());
                }
                file.Close();
            }
            return(_instance);
        }