Ejemplo n.º 1
0
        public static void ManageFrenchDictionary(Translation translation)
        {
            string userInput = EnterFrenchWord.enterFrenchWord();

            bool isWordInDictionary = Translation.VerifyWordInDictionary(userInput);

            if (isWordInDictionary)
            {
                Console.WriteLine($"The word '{userInput}' was not added to the dictionary because it already exist in the dictionary.\n");
            }


            if (!isWordInDictionary)
            {
                Console.WriteLine($"The word '{userInput}' does not exist in the dictionary.");
                Console.WriteLine("Would you like to add it to the dictionary (Y or N)?");
                string answer = Console.ReadLine().ToUpper();
                if (answer == "Y")
                {
                    translation.NewMethod_AddEnglishWordToDictionary(userInput);
                }

                if (answer == "N")
                {
                    Console.WriteLine($"You have chosen not to add the word '{userInput}' to the dictionay.");
                }
            }

            translation.SaveFrenchDictionaryToFile();
            translation.PrintDictionary();

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        public static void frenchDictionary()
        {
            bool        terminateProgram = false;
            Translation translation      = new Translation();

            while (terminateProgram == false)
            {
                Console.WriteLine("Would you like to update the french dictionary or use it?");
                Console.WriteLine("To update, Enter 1");
                Console.WriteLine("To use it, enter 2");
                Console.WriteLine("To exit, enter 3");
                int i = int.Parse(Console.ReadLine());
                if (i == 3)
                {
                    terminateProgram = true;
                }
                if (i == 1)
                {
                    translation.LoadFrenchFileToDictionary();

                    bool   updateDictionary = true;
                    string answer;
                    do
                    {
                        FrenchManage.ManageFrenchDictionary(translation);
                        Console.WriteLine("Would you like to enter another word?");
                        answer = Console.ReadLine().ToUpper();

                        if (answer == "N")
                        {
                            Console.WriteLine("Thank you for using the dictionary , you can close the app with any key");
                            updateDictionary = false;
                            Console.ReadKey();
                        }
                    } while (updateDictionary);
                    break;
                }
                if (i == 2)
                {
                    translation.LoadFrenchFileToDictionary();


                    Dictionary <string, string> englishDictionary = translation.GetDictionary();


                    string userInput = EnterFrenchWord.enterFrenchWord();
                    string translatedWord;
                    if (englishDictionary.ContainsKey(userInput))
                    {
                        translatedWord = englishDictionary[userInput];
                        Console.WriteLine($"The translation of the word '{userInput}' is '{translatedWord}'");
                    }
                    else
                    {
                        Console.WriteLine("The word you entered is not in the dictionary");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void AddFrenchWordToDictionary(string userInput, bool isWordInDictionary)
        {
            if (isWordInDictionary == false)
            {
                Console.WriteLine("This word does not exist in the dictionary.");
                Console.WriteLine("Would you like to add it to the dictionary (Y or N)?");
                string answer = Console.ReadLine().ToUpper();

                if (answer == "Y")
                {
                    NewMethod_AddFrenchWordToDictionary(userInput);
                    return;
                }
                if (answer == "N")
                {
                    Console.WriteLine($"You have chosen not to add the word '{userInput}' to the dictionay.");
                    Console.WriteLine("Would you like to enter another word?");
                    answer = Console.ReadLine().ToUpper();

                    while (true)
                    {
                        if (answer == "N")
                        {
                            Console.WriteLine("Thank you for using the dictionary , you can close the app with any key");
                            Console.ReadKey();
                        }

                        if (answer == "Y")
                        {
                            EnterFrenchWord.enterFrenchWord();
                            continue;
                        }
                    }
                }
            }
        }