From 25f8e07b0b6ca991982cf8c2a9556dd98d6db731 Mon Sep 17 00:00:00 2001 From: Quentin Snow Date: Mon, 6 Feb 2023 18:20:53 -0600 Subject: [PATCH] Money << takes abs of cents when printing --- src/models/money.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/money.cpp b/src/models/money.cpp index 2ae2cf2..6d84ed7 100644 --- a/src/models/money.cpp +++ b/src/models/money.cpp @@ -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; }