Example #1
0
        static void WriteContacts(PhoneBook phoneBook)
        {
            if (phoneBook.CountContacts() == 0)
            {
                Console.WriteLine("List is empty");
                return;
            }

            foreach (Contact contact in phoneBook.GetContacts())
            {
                Console.WriteLine($"Name: {contact.Name} PersonalPhone: {contact.PersonalPhone} Phone {contact.Phone} Description {contact.Description}");
            }
        }
Example #2
0
        static void RemoveContact(PhoneBook phoneBook)
        {
            Console.WriteLine("Enter name");
            string name = Console.ReadLine();

            Contact contact = phoneBook.FindContact(name);

            if (contact == null)
            {
                return;
            }

            phoneBook.RemoveContact(contact);
        }
Example #3
0
        static void AddContact(PhoneBook phoneBook)
        {
            Console.WriteLine("Enter name");
            string name = Console.ReadLine();

            Contact contact = new Contact(name);

            Console.WriteLine("Enter PersonalPhone");
            contact.PersonalPhone = Console.ReadLine();

            Console.WriteLine("Enter Phone");
            contact.Phone = Console.ReadLine();

            Console.WriteLine("Enter Description");
            contact.Description = Console.ReadLine();

            phoneBook.AddContact(contact);

            Console.WriteLine("Contact successfully added");
        }