示例#1
0
        public static void AddEntriesFromFile(PhoneDirectory input)
        {
            const string path     = "../../contacts.txt";
            var          readText = File.ReadAllLines(path);
            var          updated  = 0;
            var          created  = 0;

            foreach (var s in readText)
            {
                if (!s.Equals(" "))
                {
                    string[] line = s.Split(new string[] { ", " }, StringSplitOptions.None);
                    if (input.PutNumber(line[0], line[1]) == "updated")
                    {
                        updated++;
                    }
                    else
                    {
                        created++;
                    }
                }
            }
            Console.WriteLine($"{readText.Length} contacts processed!");
            Console.WriteLine($"{updated} contact(s) updated, {created} contact(s) created.");
            Console.ReadKey();
        }
示例#2
0
        private static void Main(string[] args)
        {
            PhoneDirectory myDirectory = new PhoneDirectory("Marija B.", "22222222");

            myDirectory.PutNumber("Jon Snow", "999999999");
            myDirectory.PrintPhoneDirectory();
            myDirectory.GetNumber("Marija B.");
        }
示例#3
0
        public static void AddEntryToPb(PhoneDirectory input)
        {
            Console.WriteLine("Please enter contact name:");
            var name = Console.ReadLine();

            Console.WriteLine("Please enter contact number:");
            var number = Console.ReadLine();

            input.PutNumber(name, number);
            Console.WriteLine("Contact added!");
            Console.ReadKey();
        }