summaryrefslogtreecommitdiff
path: root/include/book_store/book_count.hh
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-05-31 00:00:12 -0700
committerFuwn <[email protected]>2024-05-31 00:20:41 -0700
commit968e1c4af014b7f40bfaa4f57fcc0f38e5e0d847 (patch)
treedf80525ad0cc9e4b561bfb0772c30ccc5b64b4a2 /include/book_store/book_count.hh
parentfeat: initial commit (diff)
downloadcst_136_assignment_eight-main.tar.xz
cst_136_assignment_eight-main.zip
feat: final releaseHEADmain
Diffstat (limited to 'include/book_store/book_count.hh')
-rw-r--r--include/book_store/book_count.hh30
1 files changed, 25 insertions, 5 deletions
diff --git a/include/book_store/book_count.hh b/include/book_store/book_count.hh
index a9c68c1..29e599b 100644
--- a/include/book_store/book_count.hh
+++ b/include/book_store/book_count.hh
@@ -2,7 +2,6 @@
#define BOOK_COUNT_HH
#include <ostream>
-#include <string>
namespace book_store::product {
class book_count {
@@ -16,8 +15,10 @@ public:
book_count() = default;
book_count(book_count_type count) : _count(count) {}
- friend auto operator<<(std::ostream &output_stream, const book_count &price)
- -> std::ostream & {
+ [[nodiscard]] auto value() const noexcept -> book_count_type;
+
+ friend auto operator<<(std::ostream &output_stream,
+ const book_count &price) -> std::ostream & {
output_stream << price._count;
return output_stream;
@@ -27,10 +28,29 @@ public:
return lhs._count == rhs._count;
}
- friend auto operator+(const book_count &lhs, const book_count &rhs)
- -> book_count {
+ friend auto operator+(const book_count &lhs,
+ const book_count &rhs) -> book_count {
return {lhs._count + rhs._count};
}
+
+ friend auto operator<(const book_count &lhs, const book_count &rhs) -> bool {
+ return lhs._count < rhs._count;
+ }
+
+ friend auto operator-(const book_count &lhs,
+ const book_count &rhs) -> book_count {
+ return {lhs._count - rhs._count};
+ }
+
+ friend auto operator%(const book_count &lhs,
+ const book_count &rhs) -> book_count {
+ return {lhs._count % rhs._count};
+ }
+
+ friend auto operator*(const book_count &lhs,
+ const book_count &rhs) -> book_count {
+ return {lhs._count * rhs._count};
+ }
};
} // namespace book_store::product