Beispiel #1
0
        private static void GeneratePhoneContacts(string phonesPath)
        {
            try
            {
                var reader = new StreamReader(phonesPath);

                using (reader)
                {
                    string currLine = reader.ReadLine();

                    while (currLine != null)
                    {
                        string[] entryTokens = currLine.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

                        string name  = entryTokens[0].Trim();
                        string town  = entryTokens[1].Trim();
                        string phone = entryTokens[2].Trim();

                        Phonebook.Add(name, town, phone);

                        currLine = reader.ReadLine();
                    }
                }
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Phones file not found!");
                Console.WriteLine("Press any key");
                Console.ReadKey();
                Environment.Exit(0);
            }
        }
Beispiel #2
0
        private static void Test1()
        {
            var book = new PhoneBook();

            book.Add("Ivan", "1", "2");
            book.Add("Ivan Vankata", "3", "4");

            Console.WriteLine(book.Find("Ivan"));
            Console.WriteLine();
            Console.WriteLine(book.Find("Ivan", "3"));
        }
Beispiel #3
0
        public static void Main()
        {
            HashSet<string> phoneEntriesInput = ReadFile("../../phones.txt");
            HashSet<string> commandsInput = ReadFile("../../commands.txt");
            IList<Entry> phoneEntries = ParsePhoneEntries(phoneEntriesInput);

            PhoneBook phoneBook = new PhoneBook();

            foreach (var entry in phoneEntries)
            {
                phoneBook.Add(entry);
            }

            IList<ICommand<Entry>> commands = ParsePhonebookCommands(commandsInput, phoneBook);

            foreach (var command in commands)
            {
                var result = command.Execute();
            }
        }
Beispiel #4
0
        private static void Test1()
        {
            var book = new PhoneBook();

            book.Add("Ivan", "1", "2");
            book.Add("Ivan Vankata", "3", "4");

            Console.WriteLine(book.Find("Ivan"));
            Console.WriteLine();
            Console.WriteLine(book.Find("Ivan", "3"));
        }