Money << takes abs of cents when printing
This commit is contained in:
parent
8f44a9d46f
commit
25f8e07b0b
@ -32,9 +32,9 @@ bool operator<(const Money &lhs, const Money &rhs) {
|
|||||||
|
|
||||||
std::ostream &operator<<(std::ostream &os, const Money &money) {
|
std::ostream &operator<<(std::ostream &os, const Money &money) {
|
||||||
os << "$" << money.getDollars() << ".";
|
os << "$" << money.getDollars() << ".";
|
||||||
if (money.getCents() < 10) {
|
if (std::abs(money.getCents()) < 10) {
|
||||||
os << "0";
|
os << "0";
|
||||||
}
|
}
|
||||||
os << money.getCents();
|
os << std::abs(money.getCents());
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user