Пример #1
0
        public TheWord ShowTheWord()
        {
            try
            {
                var CurrentWords = Dictionary.Where(p => p.NumberOfCorrectAnswers != 3).Take(5).ToArray();

                var EnglishWord = CurrentWords[new Random().Next(0, CurrentWords.Length)];

                var RussianWord = CurrentWords[new Random().Next(0, CurrentWords.Length)];

                var Word = new TheWord(RussianWord.Russian, EnglishWord.English);
                return(Word);
            }
            catch
            {
                return(null);
            }
        }
Пример #2
0
        public bool CheckTheAnswer(TheWord _word, bool suppose)
        {
            var CurrentWords = Dictionary.Where(p => p.NumberOfCorrectAnswers != 3).Take(5).ToList();

            var contains = CurrentWords?.Find(p => p.English == _word.English && p.Russian == _word.Russian);

            if ((contains == null && suppose == false) || (contains != null && suppose == true))
            {
                if (suppose == true)
                {
                    Dictionary.Find(p => p.English == _word.English).NumberOfCorrectAnswers += 1;
                    File.WriteAllText(PathToTheFile, JsonConvert.SerializeObject(Dictionary));
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
 static public bool CheckFalseTheAnswer(TheWord _word, User user)
 {
     return(user.CheckTheAnswer(_word, false));
 }
Пример #4
0
 static public bool CheckTrueTheAnswer(TheWord _word, User user)
 {
     return(user.CheckTheAnswer(_word, true));
 }