diff options
| author | Fuwn <[email protected]> | 2022-06-09 22:10:55 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-06-09 22:10:55 -0700 |
| commit | 3f07f307569afce65e0ed96499e344f8c2656198 (patch) | |
| tree | 0a8938ebd967d575678ddd3c83c206074331ca2b /src/ZooAnimal.cc | |
| download | zoo-main.tar.xz zoo-main.zip | |
Diffstat (limited to 'src/ZooAnimal.cc')
| -rw-r--r-- | src/ZooAnimal.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/ZooAnimal.cc b/src/ZooAnimal.cc new file mode 100644 index 0000000..6bfa1d2 --- /dev/null +++ b/src/ZooAnimal.cc @@ -0,0 +1,44 @@ +#include <utility> + +#include "ZooAnimal.hh" + +namespace zoo { +ZooAnimal::~ZooAnimal() = default; + +void ZooAnimal::setIDNum(int _idNumber) { this->idNumber = _idNumber; } + +void ZooAnimal::setCageNum(int _cageNumber) { + if (validateCageNumber(_cageNumber)) { + this->cageNumber = _cageNumber; + } +} + +void ZooAnimal::setDateAcq(int _dateAcquired) { + this->dateAcquired = _dateAcquired; +} + +void ZooAnimal::setSpecies(std::string _species) { + this->species = std::move(_species); +} + +int ZooAnimal::getIDNum() const { return this->idNumber; } + +int ZooAnimal::getCageNum() const { return this->cageNumber; } + +int ZooAnimal::getDateAcq() const { return this->dateAcquired; } + +std::string ZooAnimal::getSpecies() { return this->species; } + +bool ZooAnimal::validateCageNumber(int _cageNumber) { + if (this->zoo != nullptr) { + for (std::size_t i = 0; + i < static_cast<std::size_t>(this->zoo->getNumCages()); ++i) { + if (*zoo->getCage(i) == _cageNumber) { + return true; + } + } + } + + return false; +} +} // namespace zoo |