diff options
Diffstat (limited to 'week_1/review_program/textbook.h')
| -rw-r--r-- | week_1/review_program/textbook.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/week_1/review_program/textbook.h b/week_1/review_program/textbook.h new file mode 100644 index 0000000..879b11d --- /dev/null +++ b/week_1/review_program/textbook.h @@ -0,0 +1,62 @@ +#ifndef TEXTBOOK_HH +#define TEXTBOOK_HH +#include <cstdint> + +namespace textbook { +class Textbook { +private: + // Input values + uint64_t _code; + double _single_copy_price; + uint64_t _number_on_hand; + uint64_t _prospective_enrollment; + bool _required; + bool _used; + // Fix 6 byte misalignment + const char _padding[6] = {0}; + // Evaluated values + uint64_t _amount_to_order = {0}; + double _total_cost = {0}; + +public: + // Constructors + Textbook(uint64_t code, double single_copy_price, uint64_t number_on_hand, + uint64_t prospective_enrollment, bool required, bool used) + : _code(code), _single_copy_price(single_copy_price), + _number_on_hand(number_on_hand), + _prospective_enrollment(prospective_enrollment), _required(required), + _used(used) {} + Textbook() : Textbook(0, 0, 0, 0, false, false) {} + + // Getters + auto code() const -> uint64_t; + auto single_copy_price() const -> double; + auto number_on_hand() const -> uint64_t; + auto prospective_enrollment() const -> uint64_t; + auto required() const -> bool; + auto used() const -> bool; + auto amount_to_order() const -> uint64_t; + auto total_cost() const -> double; + + // Setters + auto set_code(uint64_t) -> void; + auto set_single_copy_price(double) -> void; + auto set_number_on_hand(uint64_t) -> void; + auto set_prospective_enrollment(uint64_t) -> void; + auto set_required(bool) -> void; + auto set_used(bool) -> void; + + // Procedures + auto evaluate_needs() -> void; + + // Printers + auto print() const -> void; + auto print_needs() const -> void; + + // Operator overloads + auto operator==(const Textbook &) const -> bool; + auto operator!=(const Textbook &) const -> bool; +}; +} // namespace textbook + +#endif |