// // Created by martial.simon on 2/26/25. // #include "contact_details.hh" #include #include ContactDetails ContactDetails::makeDetails(const std::string& telephone_number, const std::string& personal_email) { for (auto digit : telephone_number) { if (!isdigit(digit)) throw std::invalid_argument{ "Phone number must only contain digits." }; } size_t i; for (i = 0; i < personal_email.length(); ++i) { if (personal_email[i] == '@') break; } if (i == personal_email.length()) throw std::invalid_argument{ "Email must contain at least one '@'." }; return ContactDetails{ telephone_number, personal_email }; } std::ostream& operator<<(std::ostream& os, const ContactDetails& dt) { os << dt.phone_ << ", " << dt.email_ << "\n"; return os; } ContactDetails::ContactDetails(const std::string& telephone_number, const std::string& personal_email) : phone_{ telephone_number } , email_{ personal_email } {}