static void Main(string[] args) { var fileRecords = ReadPhoneRecordsFromFile("phones.txt"); var commands = ReadCommandsFromFile("commands.txt"); PhoneBook book = new PhoneBook(fileRecords); ExecuteCommands(book, commands); }
private static void ExecuteCommands(PhoneBook book, List<Command> commands) { foreach (var command in commands) { if (command.Name == "find") { List<PhoneRecord> records; if (command.Parameters.Length == 1) { records = book.Find(command.Parameters[0]); } else { records = book.Find(command.Parameters[0], command.Parameters[1]); } PrintPhoneRecordsOnConsole(records); } } }
private static void ExecuteCommands(PhoneBook book, List <Command> commands) { foreach (var command in commands) { if (command.Name == "find") { List <PhoneRecord> records; if (command.Parameters.Length == 1) { records = book.Find(command.Parameters[0]); } else { records = book.Find(command.Parameters[0], command.Parameters[1]); } PrintPhoneRecordsOnConsole(records); } } }