summaryrefslogtreecommitdiff
path: root/week_1/review_program/textbook.h
blob: 879b11d4f136ceec2ff4d925efafa88e9ab2d70e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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