예제 #1
0
        public static void Add(string name, string[] translations)
        {
            WordList loadedList = WordList.LoadList(name);

            loadedList.Add(translations);

            loadedList.Save();
        }
예제 #2
0
        public static void Add(string[] args)
        {
            if (args.Length > 1)
            {
                if (File.Exists($"{WordList.LocalApplicationDirectory}{args[1]}.dat"))
                {
                    WordList loadedList = WordList.LoadList(args[1]);

                    string[] wordInput = new string[loadedList.Languages.Length];

                    do
                    {
                        if (!wordInput.Contains(null))
                        {
                            loadedList.Add(wordInput);

                            loadedList.Save();
                        }

                        Console.WriteLine("Enter translations for the new word:");

                        for (int i = 0; i < wordInput.Length; i++)
                        {
                            Console.Write($"Enter {loadedList.Languages[i]} translation: ");
                            wordInput[i] = Console.ReadLine();

                            if (wordInput[i] == "")
                            {
                                break;
                            }
                        }
                    } while (!wordInput.Contains(""));

                    loadedList.Save();
                }
                else
                {
                    Console.WriteLine("Could not find list.");
                }
            }
            else
            {
                Console.WriteLine("No list name was entered.");
            }
        }
예제 #3
0
        public static void Remove(string[] args)
        {
            if (args.Length > 3)
            {
                if (File.Exists($"{WordList.LocalApplicationDirectory}{args[1]}.dat"))
                {
                    WordList loadedList = WordList.LoadList(args[1]);

                    string[] words = new string[args.Length - 3];

                    for (int i = 0; i < words.Length; i++)
                    {
                        words[i] = args[i + 3];
                    }

                    for (int index = 0; index < loadedList.Languages.Length; index++)
                    {
                        if (loadedList.Languages[index] == args[2])
                        {
                            foreach (string word in words)
                            {
                                if (loadedList.Remove(index, word))
                                {
                                    Console.WriteLine($"Removed {word} and it's translations.");
                                }
                                else
                                {
                                    Console.WriteLine("Could not find word.");

                                    return;
                                }
                            }

                            loadedList.Save();

                            return;
                        }
                    }

                    Console.WriteLine($"Can not find language in file.");
                }
                else
                {
                    Console.WriteLine("Could not find file.");
                }
            }
            else
            {
                if (args.Length == 1)
                {
                    Console.WriteLine("Please provide list name, language and word.");
                    return;
                }
                else if (args.Length == 2)
                {
                    Console.WriteLine("Please provide language and word.");
                    return;
                }
                else
                {
                    Console.WriteLine("Please provide word.");
                }
            }
        }