aBuTaMuHo3 / oop

added lab 5
0 stars 0 forks source link

Замечания по программе Car #5

Open alexey-malov opened 7 years ago

alexey-malov commented 7 years ago

image

alexey-malov commented 7 years ago

image

alexey-malov commented 7 years ago

Алгоритмы + Структуры данных = Программы

alexey-malov commented 7 years ago
Engine is turned on
Direction is: forward
Gear is: 0
Speed is: 3
> SetGear 1
Engine is turned off or gear does not match current speed
alexey-malov commented 7 years ago
> Info
Engine is turned on
Direction is: forward
Gear is: 5
Speed is: 90
> EngineOff
> Info
Engine is turned on
Direction is: forward
Gear is: 5
Speed is: 90
alexey-malov commented 7 years ago
    // Вспомогательная функция для проверки работы команды command
    // Она принимает ожидаемый номер канала expectedChannel и expectedOutput
    void VerifyCommandHandling(const string& command, const string& expectedOutput)
    {
        // Предварительно очищаем содержимое выходного потока
        output = stringstream();
        input = stringstream();
        BOOST_CHECK(input << command);
        BOOST_CHECK(remoteControl.HandleCommand());
        BOOST_CHECK(input.eof());
        BOOST_CHECK_EQUAL(output.str(), expectedOutput);
    }
alexey-malov commented 7 years ago
        canSetGear = (gear == -1 && m_speed == 0 && m_direction <= Direction::none) || (gear == 1 && m_speed == 0 && m_direction>= Direction::none) || (gear == 0)||(gear>=2);
alexey-malov commented 7 years ago
bool CCar::SpeedIsInRange(int const &gear, int speed) const
alexey-malov commented 7 years ago
bool CCar::SpeedIsInRange(int const &gear, int speed) const
{
    auto it = speedRange.find(gear);
    auto speedRange = it->second;
    return  (speedRange.second >= speed) && (speedRange.first <= speed);
}