Money << takes abs of cents when printing

This commit is contained in:
Quentin Snow 2023-02-06 18:20:53 -06:00
parent 8f44a9d46f
commit 25f8e07b0b

View File

@ -32,9 +32,9 @@ bool operator<(const Money &lhs, const Money &rhs) {
std::ostream &operator<<(std::ostream &os, const Money &money) {
os << "$" << money.getDollars() << ".";
if (money.getCents() < 10) {
if (std::abs(money.getCents()) < 10) {
os << "0";
}
os << money.getCents();
os << std::abs(money.getCents());
return os;
}