/
plato
/
RaceProject
Обзор
Документация
Войти
/
plato
/
RaceProject
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
lib/src/GroundVehicle.cpp
32 строки
846 B
Evanivan
feat: program almost done
09 дек 2025, 22:04
09 дек 2025, 22:04
e9ce965
Код
Авторство
О чём код?
#include "GroundVehicle.h" #include <cmath> GroundVehicle::GroundVehicle(double s, const std::string& n, double driveTime) : Vehicle(s, n), drivingTime(driveTime) {} std::string GroundVehicle::getType() const { return "Ground"; } double GroundVehicle::calculateTime(double distance) const { double totalTime = 0; double remainingDistance = distance; int stopNumber = 0; while (remainingDistance > 0) { double distanceThisSegment = speed * drivingTime; if (remainingDistance <= distanceThisSegment) { totalTime += remainingDistance / speed; break; } remainingDistance -= distanceThisSegment; totalTime += drivingTime; stopNumber++; totalTime += getRestDuration(stopNumber); } return totalTime; }