diff options
Diffstat (limited to 'include/book_store/book_count.hh')
| -rw-r--r-- | include/book_store/book_count.hh | 30 |
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 |