#ifndef BOOK_STORE_HH #define BOOK_STORE_HH #include #include #include #include #include #include #include #include #include #include #include #include namespace book_store { class store { private: using books_type = std::vector; using customer_type = consumer::customer; using customer_container = std::vector; // An `std::unordered_map` would be more appropriate here, but // here we are. While we aren't using a proper database, we can // take these liberties. using transactions_type = std::vector>; using discount_percent_type = double; using size_type = std::size_t; size_type _books_max_size; size_type _customers_max_size; books_type _books; customer_container _customers; transactions_type _transactions; product::price::usd _membership_fee; discount_percent_type _membership_discount_percent; public: store() = default; store(size_type books_max_size, size_type customers_max_size) : _books_max_size(books_max_size), _customers_max_size(customers_max_size) {} store(size_type books_max_size, size_type customers_max_size, product::price::usd membership_fee, discount_percent_type membership_discount_percent) : _books_max_size(books_max_size), _customers_max_size(customers_max_size), _membership_fee(membership_fee), _membership_discount_percent(membership_discount_percent) {} store(const store &) = default; store(store &&) = default; auto append_book(const product::book &book) -> void; auto append_customer(const customer_type &person) -> void; auto purchase_book(size_type person_id, std::string_view isbn, product::book_count count) -> std::optional; auto tick_year() -> void; auto membership_fee(product::price::usd fee) -> void; auto membership_discount_percent(discount_percent_type discount_percent) -> void; [[nodiscard]] auto books_size() const noexcept -> size_type; [[nodiscard]] auto people_size() const noexcept -> size_type; [[nodiscard]] auto books_max_size() const noexcept -> size_type; [[nodiscard]] auto people_max_size() const noexcept -> size_type; [[nodiscard]] auto membership_fee() const noexcept -> product::price::usd; [[nodiscard]] auto membership_discount_percent() const noexcept -> discount_percent_type; auto find_person_by_id(size_type person_id) -> std::optional; auto find_book_by_isbn(std::string_view isbn) -> std::optional>; auto find_books_by_title(std::string_view title) -> std::vector; auto find_books_by_author(std::string_view name) -> std::vector; auto transactions_by_id(size_type person_id) -> std::vector; auto books() -> books_type &; auto people() -> customer_container &; auto operator=(const store &) -> store & = default; auto operator=(store &&) -> store & = default; }; } // namespace book_store #endif // BOOK_STORE_HH