Esempio n. 1
0
 private static void AddRecords(string[] input, PhoneRecords records)
 {
     for (int i = 0; i < input.Length; i++)
     {
         var nextRecord = new PhoneRecord(input[i]);
         records.Add(nextRecord);
     }
 }
Esempio n. 2
0
        static void Main()
        {
            var input   = ReadInputFrom(RecordsFile);
            var records = new PhoneRecords();

            AddRecords(input, records);

            var commands = ReadInputFrom(CommandsFile);

            CommandsExecute(commands, records);
        }
Esempio n. 3
0
        private static void CommandsExecute(string[] commands, PhoneRecords records)
        {
            foreach (var command in commands)
            {
                IEnumerable <PhoneRecord> commandOutput;
                var nameTown = ExtractArguments(command);
                if (nameTown.Length > 1)
                {
                    var name = nameTown[0].Trim();
                    var town = nameTown[1].Trim();
                    commandOutput = records.Find(name, town);
                }
                else
                {
                    var name = nameTown[0];
                    commandOutput = records.Find(name);
                }

                PrintOutRecords(commandOutput);
                Console.WriteLine("********************");
            }
        }