use C++ features to show price

This commit is contained in:
Martin Brodbeck 2018-07-23 21:21:05 +02:00
parent 96d0a03ba8
commit fa7938ca20
3 changed files with 37 additions and 4 deletions

View file

@ -29,9 +29,9 @@ int Article::getPrice() const { return price_; }
std::string Article::getPriceAsString() const
{
double sumInEuro = price_ / 100.0L;
std::stringstream sumStream;
sumStream << std::fixed << std::setprecision(2) << sumInEuro << "";
sumStream.imbue(std::locale("de_DE.utf8"));
sumStream << std::right << std::setw(12) << std::showbase << std::put_money(price_, false);
return sumStream.str();
}