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")); }
private static void ExecuteCommands(List <string> commands, PhoneBook phoneBook) { foreach (var command in commands) { List <PhoneEntry> found = new List <PhoneEntry>(); string[] arguments = command.Split(); if (arguments.Length == 1) { found = phoneBook.Find(arguments[0]); } else if (arguments.Length == 2) { found = phoneBook.Find(arguments[0], arguments[1]); } PrintFoundEntries(found, command); } }
private static void ExecuteCommands(List<string> commands, PhoneBook phoneBook) { foreach (var command in commands) { List<PhoneEntry> found = new List<PhoneEntry>(); string[] arguments = command.Split(); if (arguments.Length == 1) { found = phoneBook.Find(arguments[0]); } else if (arguments.Length == 2) { found = phoneBook.Find(arguments[0], arguments[1]); } PrintFoundEntries(found, command); } }
private static void ExecuteCommands(string commandsPath) { try { var reader = new StreamReader(commandsPath); using (reader) { string currLine = reader.ReadLine(); while (currLine != null) { Console.WriteLine(currLine); currLine = currLine.Substring(currLine.IndexOf('(') + 1).TrimEnd(')'); var commandTokens = currLine.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); if (commandTokens.Length == 1) { Console.WriteLine(Phonebook.Find(commandTokens[0])); } else { Console.WriteLine(Phonebook.Find(commandTokens[0], commandTokens[1])); } currLine = reader.ReadLine(); } } } catch (FileNotFoundException) { Console.WriteLine("Commands file not found!"); Console.WriteLine("Press any key"); Console.ReadKey(); Environment.Exit(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")); }