use C++ features to show price
This commit is contained in:
parent
96d0a03ba8
commit
fa7938ca20
3 changed files with 37 additions and 4 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue