static void AddWords(string[] args) { GuardClauses.NoSelectedList(args); var loadedList = WordList.LoadList(args[1]); GuardClauses.LoadedListReturnsNull(loadedList, args[1]); bool addWords = true; Regex forbiddenChars = new Regex("[0-9;\r\n]+"); while (addWords) { string[] translations = new string[loadedList.Languages.Length]; for (int i = 0; i < loadedList.Languages.Length; i++) { Console.Write($"{loadedList.Languages[i].ToUpper()}: "); translations[i] = Console.ReadLine(); if (translations[i] == "") { addWords = false; break; } translations[i] = forbiddenChars.Replace(translations[i], "").Trim(); } if (!translations.Contains("")) { loadedList.Add(translations); } } loadedList.Save(); }
static void CountWordsInSelectedList(string[] args) { GuardClauses.NoSelectedList(args); var loadedList = WordList.LoadList(args[1]); GuardClauses.LoadedListReturnsNull(loadedList, args[1]); Console.WriteLine($"There's {loadedList.Count()} words in '{loadedList.Name}'"); }
static void SortList(string[] args) { GuardClauses.NoSelectedList(args); var loadedList = WordList.LoadList(args[1]); GuardClauses.LoadedListReturnsNull(loadedList, args[1]); GuardClauses.SelectedListDoesntContainWords(loadedList); if (args.Length < 3) { loadedList.List(0, ShowTranslation); } else { GuardClauses.SelectedListDoesntContainLanguage(loadedList, args[2]); string language = args[2]; int index = Array.FindIndex(loadedList.Languages, l => l.Contains(language)); loadedList.List(index, ShowTranslation); } }
static void PracticeWords(string[] args) { GuardClauses.NoSelectedList(args); var loadedList = WordList.LoadList(args[1]); GuardClauses.LoadedListReturnsNull(loadedList, args[1]); GuardClauses.SelectedListDoesntContainWords(loadedList); PracticeConsole.ResetPractice(); while (true) { Word randomWord = loadedList.GetWordToPractice(); PracticeConsole practiceMode = new PracticeConsole(randomWord, loadedList); practiceMode.Play(); string userInput = Console.ReadLine(); if (userInput == "") { practiceMode.PrintTotalScore(); break; } practiceMode.PrintRightOrWrong(userInput); } }