aBuTaMuHo3 / oop

added lab 5
0 stars 0 forks source link

Замечания по программе Rational #2

Open alexey-malov opened 7 years ago

alexey-malov commented 7 years ago
        BOOST_AUTO_TEST_CASE(can_sum_two_rational_numbers)
        {
            VerifyRational(CRational(1, 2) += CRational(1, 6), 2, 3);

            {
                CRational r1(3, 1);
                CRational r2(2, 1);
                CRational r3(1, 1);
                //(r1 += r2) += r3; // <---------------------------
                //VerifyRational(r1, 6, 1);
                VerifyRational(r2, 2, 1);
                VerifyRational(r3, 1, 1);
            }
            {
                int i1 = 3;
                int i2 = 2;
                int i3 = 1;
                (i1 += i2) += i3;
                BOOST_CHECK_EQUAL(i1, 6);
                BOOST_CHECK_EQUAL(i2, 2);
                BOOST_CHECK_EQUAL(i3, 1);
            }
        }
alexey-malov commented 7 years ago
    CRational const operator +() const;
    CRational const operator -();
alexey-malov commented 7 years ago
int x;
CRational y;
...
auto z = x + y; // ожидается, что z - рациональное число

if (z < 3) // вместо if (z < CRational(3))
{
}
alexey-malov commented 7 years ago
//////////////////////////////////////////////////////////////////////////
// TODO: 11. Реализовать операторы == и !=
//////////////////////////////////////////////////////////////////////////

bool const operator ==(CRational const& first, CRational const& second)
{
    return true;/* (first.GetNumerator() == second.GetNumerator()) &&
        (first.GetDenominator() == second.GetDenominator());*/
}

bool const operator !=(CRational const& first, CRational const& second)
{
    return true; /*(first.GetNumerator() != second.GetNumerator()) ||
        (first.GetDenominator() != second.GetDenominator());*/
}
//////////////////////////////////////////////////////////////////////////
// TODO: 12. Реализовать операторы <, >, <=, >=
//////////////////////////////////////////////////////////////////////////

bool const operator <(CRational const& first, CRational const& second)
{
    return true;// ((first.GetNumerator() * second.GetDenominator()) < (first.GetDenominator() * second.GetNumerator()));
}

bool const operator >(CRational const& first, CRational const& second)
{
    return true; /*((first.GetNumerator() * second.GetDenominator()) > (first.GetDenominator() * second.GetNumerator()));*/
}
bool const operator <=(CRational const& first, CRational const& second)
{
    return true;/* !(first > second);*/
}

bool const operator >=(CRational const& first, CRational const& second)
{
    return true;/* !(first < second);*/
}