public void Load()
        {
            string[] lines = File.ReadAllLines(PathToWordsFile);
            if (lines.Length == 0)
            {
                throw new IOException("Empty file");
            }
            int currentLineNumber = 1;

            try
            {
                foreach (string line in lines)
                {
                    string[] columns        = line.Split(',');
                    string   original       = columns[0];
                    string   translation    = columns[1];
                    string   note           = columns.Length > 2 ? columns[2] : "";
                    uint     correctCount   = columns.Length > 3 ? uint.Parse(columns[3]) : 0;
                    uint     incorrectCount = columns.Length > 4 ? uint.Parse(columns[4]) : 0;
                    WordsList.Add(new Word(original, translation, note, correctCount, incorrectCount));
                    currentLineNumber++;
                }
            }
            catch (Exception)
            {
                throw new FormatException("Bad input file format on line " + currentLineNumber);
            }
        }
Exemple #2
0
 public void Add(params string[] translations)
 {
     if (WordsList != null)
     {
         var word = new Word(translations);
         WordsList.Add(word);
     }
 }
Exemple #3
0
        public void Tests()
        {
            var list = new WordsList(new[] {"Pie", "tomato"});
            list.Add("Pieapple");

            var linkedList = new WordsLinkedList(new[] {"Pie", "Tomato"});
            linkedList.AddLast("Pieapple");

            var search1 = new LikeSearcher("Pie");
            list.Browse(search1);
            CollectionAssert.AreEqual(new[] {"Pie", "Pieapple"}, search1.Matches.ToArray());

            var search2 = new LikeSearcher("Pie");
            linkedList.Browse(search2);
            CollectionAssert.AreEqual(new[] { "Pie", "Pieapple" }, search2.Matches.ToArray());
        }
        public void Tests()
        {
            var list = new WordsList(new[] { "Pie", "tomato" });

            list.Add("Pieapple");

            var linkedList = new WordsLinkedList(new[] { "Pie", "Tomato" });

            linkedList.AddLast("Pieapple");

            var search1 = new LikeSearcher("Pie");

            list.Browse(search1);
            CollectionAssert.AreEqual(new[] { "Pie", "Pieapple" }, search1.Matches.ToArray());

            var search2 = new LikeSearcher("Pie");

            linkedList.Browse(search2);
            CollectionAssert.AreEqual(new[] { "Pie", "Pieapple" }, search2.Matches.ToArray());
        }
 public void FillWordLists()
 {
     WordsList.Clear();
     TranslationList.Clear();
     for (; count <= selectedWordsList.Count; count++)
     {
         WordsList.Add(selectedWordsList[count - 1].Word);
         TranslationList.Add(selectedWordsList[count - 1].Translation);
         if (count == edge)
         {
             partOfGame = PartOfGame.TypeWords;
             count++;
             break;
         }
         if (count % 5 == 0 && count != 0 && partOfGame == PartOfGame.MatchWords)
         {
             count++;
             break;
         }
     }
 }
 public void AddWord(String word)
 {
     WordsList.Add(word);
 }