/// <summary>
        /// Interactively creates a new fax number.
        /// </summary>
        /// <returns>The new fax number.</returns>
        public new static FaxNumber Create()
        {
            string number = MainFunctions.GetAndValidateInput("Fax Number", RegexPatterns.PhoneNumber);

            FaxNumber newFaxNumber = new FaxNumber(number);

            return(newFaxNumber);
        }
 public override bool Equals(object obj)
 {
     if (obj == null || GetType() != obj.GetType())
     {
         return(false);
     }
     else
     {
         FaxNumber that = (FaxNumber)obj;
         return(base.Equals(that));
     }
 }
示例#3
0
        /// <summary>
        /// Interactively creates a new contact.
        /// </summary>
        /// <returns>The new contact.</returns>
        public static Contact Create()
        {
            string firstName = MainFunctions.GetAndValidateInput("First Name", RegexPatterns.Name);
            string lastName  = MainFunctions.GetAndValidateInput("Last Name", RegexPatterns.Name);
            string fullName  = string.Format("{0} {1}", firstName, lastName);

            Contact newContact = new Contact(fullName);

            bool addAddresses = !MainFunctions.InputStartsWith("Add addresses? (Y/n) ", "n");

            if (addAddresses)
            {
                while (true)
                {
                    Console.Clear();

                    Address newAddress = Address.Create();
                    Console.WriteLine(newAddress);

                    bool addressOK = !MainFunctions.InputStartsWith("Is this address OK? (Y/n) ", "n");

                    if (addressOK)
                    {
                        newContact.Addresses.Add(newAddress);
                        Console.WriteLine("Added new address to new contact's set of addresses.");
                    }
                    else
                    {
                        Console.WriteLine("Discarded new address.");
                    }

                    bool addAnother = !MainFunctions.InputStartsWith("Add another? (Y/n) ", "n");
                    if (!addAnother)
                    {
                        break;
                    }
                }
            }

            bool addPhoneNumbers = !MainFunctions.InputStartsWith("Add phone numbers? (Y/n) ", "n");

            if (addPhoneNumbers)
            {
                while (true)
                {
                    Console.Clear();

                    PhoneNumber newPhoneNumber = PhoneNumber.Create();
                    Console.WriteLine(newPhoneNumber);

                    bool addressOK = !MainFunctions.InputStartsWith("Is this phone number OK? (Y/n) ", "n");

                    if (addressOK)
                    {
                        newContact.PhoneNumbers.Add(newPhoneNumber);
                        Console.WriteLine("Added new phone number to new contact's set of phone numbers.");
                    }
                    else
                    {
                        Console.WriteLine("Discarded new phone number.");
                    }

                    bool addAnother = !MainFunctions.InputStartsWith("Add another? (Y/n) ", "n");
                    if (!addAnother)
                    {
                        break;
                    }
                }
            }

            bool addFaxNumbers = !MainFunctions.InputStartsWith("Add fax numbers? (Y/n) ", "n");

            if (addFaxNumbers)
            {
                while (true)
                {
                    Console.Clear();

                    FaxNumber newFaxNumber = FaxNumber.Create();
                    Console.WriteLine(newFaxNumber);

                    bool addressOK = !MainFunctions.InputStartsWith("Is this fax number OK? (Y/n) ", "n");

                    if (addressOK)
                    {
                        newContact.FaxNumbers.Add(newFaxNumber);
                        Console.WriteLine("Added new fax number to new contact's set of fax numbers.");
                    }
                    else
                    {
                        Console.WriteLine("Discarded new fax number.");
                    }

                    bool addAnother = !MainFunctions.InputStartsWith("Add another? (Y/n) ", "n");
                    if (!addAnother)
                    {
                        break;
                    }
                }
            }

            bool addEmailAddresses = !MainFunctions.InputStartsWith("Add email addresses? (Y/n) ", "n");

            if (addEmailAddresses)
            {
                while (true)
                {
                    Console.Clear();

                    EmailAddress newEmailAddress = EmailAddress.Create();
                    Console.WriteLine(newEmailAddress);

                    bool emailAddressOK = !MainFunctions.InputStartsWith("Is this email address OK? (Y/n) ", "n");

                    if (emailAddressOK)
                    {
                        newContact.EmailAddresses.Add(newEmailAddress);
                        Console.WriteLine("Added new email address to new contact's set of email addresses.");
                    }
                    else
                    {
                        Console.WriteLine("Discarded new email address.");
                    }

                    bool addAnother = !MainFunctions.InputStartsWith("Add another? (Y/n) ", "n");
                    if (!addAnother)
                    {
                        break;
                    }
                }
            }

            return(newContact);
        }