private static void AddSubscribersToPhonebook(Phonebook phoneBook) { phoneBook.AddSubscriber(new Subscriber("unknown", "varna", "321")); phoneBook.AddSubscribers(new List<Subscriber>() { new Subscriber("Daniela Mimi Petrova", "Karnobat", "0899 999 888"), new Subscriber("Mimi Loshata", "Pernik", "0888 12 34 5") }); }
public static void Main() { var phoneTextFileContent = FileUtility.GetFileTextContent("../../phones.txt"); var commandsTextFileContent = FileUtility.GetFileTextContent("../../commands.txt"); var subcribers = ExtractSubscribers(phoneTextFileContent); Phonebook phoneBook = new Phonebook(subcribers); AddSubscribersToPhonebook(phoneBook); Console.WriteLine(phoneBook); Console.WriteLine(new string('-', 33) + "SEARCH RESULTS:" + new string('-', 32) + Environment.NewLine); ExecuteCommands(phoneBook, commandsTextFileContent); }
private static void ExecuteCommands(Phonebook phonebook, string text) { var commands = ExtractCommands(text); foreach (var command in commands) { if (command[0] == "find") { if (command.Count == 2) { PrintResult(phonebook.Find(command[1]), command[1]); } else if (command.Count == 3) { PrintResult(phonebook.Find(command[1], command[2]), command[1], command[2]); } } } }