示例#1
0
        static void Main(string[] args)
        {
            var fileRecords = ReadPhoneRecordsFromFile("phones.txt");
            var commands = ReadCommandsFromFile("commands.txt");

            PhoneBook book = new PhoneBook(fileRecords);
            ExecuteCommands(book, commands);
        }
示例#2
0
        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);
                }
            }
        }
示例#3
0
        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);
                }
            }
        }