Re-formatted all source files

This commit is contained in:
Michael Mandl 2019-10-05 16:14:45 +02:00
parent 5c6ed8191b
commit d0f64ef440
77 changed files with 2443 additions and 2332 deletions

View file

@ -9,58 +9,58 @@ Age::Age(unsigned int years, unsigned int months)
{
}
Age::Age(const QDate &birth, const QDate &reference)
Age::Age(const QDate& birth, const QDate& reference)
{
if (reference < birth)
{
qDebug() << "test (" << reference << ") before birth (" << birth << ")";
m_years = 0;
m_months = 0;
if (reference < birth)
{
qDebug() << "test (" << reference << ") before birth (" << birth << ")";
m_years = 0;
m_months = 0;
return;
}
return;
}
int years = reference.year() - birth.year();
int months = reference.month() - birth.month();
int years = reference.year() - birth.year();
int months = reference.month() - birth.month();
if (months == 0 && reference.day() < birth.day())
{
months--;
}
if (months == 0 && reference.day() < birth.day())
{
months--;
}
if (months < 0)
{
years--;
months = (months + 12) % 12;
}
if (months < 0)
{
years--;
months = (months + 12) % 12;
}
m_years = years;
m_months = months;
m_years = years;
m_months = months;
}
bool Age::operator<(const Age &cmp) const
bool Age::operator<(const Age& cmp) const
{
if (m_years == cmp.m_years)
{
return m_months < cmp.m_months;
}
if (m_years == cmp.m_years)
{
return m_months < cmp.m_months;
}
return m_years < cmp.m_years;
return m_years < cmp.m_years;
}
unsigned int Age::years() const
{
return m_years;
return m_years;
}
unsigned int Age::months() const
{
return m_months;
return m_months;
}
std::string Age::toString() const
{
std::ostringstream result;
result << m_years << ";" << m_months;
return result.str();
std::ostringstream result;
result << m_years << ";" << m_months;
return result.str();
}

View file

@ -5,18 +5,18 @@
class Age
{
private:
unsigned int m_years = 0;
unsigned int m_months = 0;
unsigned int m_years = 0;
unsigned int m_months = 0;
public:
Age() = default;
Age(unsigned int years, unsigned int months);
Age(const QDate &birth, const QDate &reference);
Age() = default;
Age(unsigned int years, unsigned int months);
Age(const QDate& birth, const QDate& reference);
bool operator<(const Age &cmp) const;
bool operator<(const Age& cmp) const;
unsigned int years() const;
unsigned int months() const;
unsigned int years() const;
unsigned int months() const;
std::string toString() const;
std::string toString() const;
};