Example and test package code changed to use text formatting

This commit is contained in:
Mateusz Pusz
2019-10-19 00:08:25 +02:00
parent 53720c82b8
commit b2f33c6dfa
2 changed files with 5 additions and 5 deletions

View File

@ -37,8 +37,8 @@ template<units::Velocity V, units::Time T>
void example_1(V v, T t)
{
const units::Length AUTO distance = v * t;
std::cout << "A car driving " << v.count() << " km/h in a time of " << t.count() << " minutes will pass "
<< units::quantity_cast<units::quantity<units::metre, double>>(distance).count() << " metres.\n";
std::cout << "A car driving " << v << " in a time of " << t << " will pass "
<< units::quantity_cast<units::quantity<units::metre, double>>(distance) << ".\n";
}
void example_2(double distance_v, double duration_v)
@ -46,8 +46,8 @@ void example_2(double distance_v, double duration_v)
units::quantity<units::kilometre> distance(distance_v);
units::quantity<units::hour> duration(duration_v);
const auto kmph = quantity_cast<units::kilometre_per_hour>(avg_speed(distance, duration));
std::cout << "Average speed of a car that makes " << distance.count() << " km in "
<< duration.count() << " hours is " << kmph.count() << " km/h.\n";
std::cout << "Average speed of a car that makes " << distance << " in "
<< duration << " is " << kmph << ".\n";
}
}

View File

@ -33,5 +33,5 @@ constexpr units::Velocity avg_speed(D d, T t)
int main()
{
std::cout << "Average speed = " << avg_speed(240.0km, 2h).count() << " kmph\n";
std::cout << "Average speed = " << avg_speed(240.km, 2h) << '\n';
}