LikhachevAV / OOP2016

0 stars 0 forks source link

Замечания по программе Student #9

Open alexey-malov opened 7 years ago

alexey-malov commented 7 years ago
    if ((name.length() > 0) && (name.compare(" ") != 0) && 
        (surname.length() > 0) && (surname.compare(" ") != 0))
    {
alexey-malov commented 7 years ago
void CStudent::Rename(std::string const & name, std::string const & surname, std::string const & patronymic)
{
    if ((name.length() > 0) && (name.compare(" ") != 0) &&
        (surname.length() > 0) && (surname.compare(" ") != 0))
    {
        m_name = name;
        m_surname = surname;
    }
    else
    {
        throw std::invalid_argument("Names and surnames values must be non empty and non space value");
    }

    if ((name.length() > 0) && (patronymic.compare(" ") == 0))
    {
        throw std::invalid_argument("Patronymic value must non space value");
    }
    else
    {
        m_patronymic = patronymic;
    }
}
alexey-malov commented 7 years ago
bool StringContainOnlySpaces(std::string const & s)
{
    for (int i = 0; i < (int)s.length(); ++i)
    {
        if (s[i] != ' ')
        {
            return false;
        }
    }
    return true;
}
alexey-malov commented 7 years ago
    try
    {
        m_name = name;
        m_surname = surname;
        m_patronymic = patronymic;
    }
    catch (std::exception)
    {
        throw;
    }
alexey-malov commented 7 years ago
alexey-malov commented 7 years ago

image