Example #1
0
        } // end EditBasicContact()

        public static void EditInstructorContact(InstructorContact contact, ref int choice)
        { // Allow editing of an InstructorContact. Appropriate fields are error checked, while others are not.
            switch (choice)
            {
            case 0:
                Console.Write("Enter the new first name: ");
                contact.first = Console.ReadLine();
                break;

            case 1:
                Console.Write("Enter the new last name: ");
                contact.last = Console.ReadLine();
                break;

            case 2:
                contact.phone = GetValidPhoneNumber(true);
                break;

            case 3:
                contact.email = GetValidEmail(true);
                break;

            case 4:
                Console.Write("Enter the new office location: ");
                contact.office = Console.ReadLine();
                break;

            default:
                break;
            }
        } // end EditInstructorContact()
Example #2
0
        } // end ListAllContacts()

        public static void CreateNewContact(ref List <Contact> contacts)
        { // Get information on the new contact and add them to the List<>. Changes are saved when the program exits.
            string  first, last, office, isInstr = "";
            Contact contact;

            Console.WriteLine("\n*** Creating New Contact ***");
            Console.Write("\nFirst name: ");
            first = Console.ReadLine();
            Console.Write("Last name: ");
            last = Console.ReadLine();

            do
            {
                Console.Write("Is instructor? (y/n): ");
                isInstr = Console.ReadLine().ToLower();
            } while(isInstr != "y" && isInstr != "n");

            if (isInstr == "n")
            {
                contact = new Contact(first, last);
            }
            else // if(isInstr == "y")
            {
                contact = new InstructorContact(first, last);
            }

            contact.phone = GetValidPhoneNumber(false);

            contact.email = GetValidEmail(false);

            if (contact is InstructorContact ic)
            {
                Console.Write("Office location: ");
                office    = Console.ReadLine();
                ic.office = office;
                contacts.Add(ic);
            }
            else
            {
                contacts.Add(contact);
            }
        } // end CreateNewContact()