diff options
| author | Fuwn <[email protected]> | 2024-05-26 18:01:25 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-05-26 18:01:25 -0700 |
| commit | fa3595d69f817ad1a67b7189ed65dbde1ba9f77d (patch) | |
| tree | ae85e0ba5f132ce89021cc1e4bcea4e642ffee6c /source/person.cc | |
| download | cst_136_assignment_eight-fa3595d69f817ad1a67b7189ed65dbde1ba9f77d.tar.xz cst_136_assignment_eight-fa3595d69f817ad1a67b7189ed65dbde1ba9f77d.zip | |
feat: initial commit
Diffstat (limited to 'source/person.cc')
| -rw-r--r-- | source/person.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/source/person.cc b/source/person.cc new file mode 100644 index 0000000..e80e6df --- /dev/null +++ b/source/person.cc @@ -0,0 +1,43 @@ +#include <cstddef> +#include <string> +#include <string_view> + +#include <book_store/person.hh> + +namespace book_store::consumer { +auto person::last_name() const noexcept -> std::string_view { + return this->_last_name; +} + +auto person::first_name() const noexcept -> std::string_view { + return this->_first_name; +} + +auto person::full_name(bool last_first) const noexcept -> std::string { + if (last_first) { + return this->_last_name + ", " + this->_first_name; + } + + return this->_first_name + " " + this->_last_name; +} + +auto person::id() const noexcept -> std::size_t { return this->_id; } + +auto person::last_name(std::string_view last_name) noexcept -> person & { + this->_last_name = last_name; + + return *this; +} + +auto person::first_name(std::string_view first_name) noexcept -> person & { + this->_first_name = first_name; + + return *this; +} + +auto person::id(std::size_t person_id) noexcept -> person & { + this->_id = person_id; + + return *this; +} +} // namespace book_store::consumer |