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); } }
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); } }
static public bool CheckFalseTheAnswer(TheWord _word, User user) { return(user.CheckTheAnswer(_word, false)); }
static public bool CheckTrueTheAnswer(TheWord _word, User user) { return(user.CheckTheAnswer(_word, true)); }