#include #include #include "Zoo.hh" namespace zoo { Zoo::~Zoo() { delete[] this->exhibits; delete[] this->cages; } void Zoo::setExhibit(std::string exhibit) { auto *newExhibits = new std::string[static_cast(this->numExhibits + 1)]; std::copy(this->exhibits, this->exhibits + static_cast(this->numExhibits), newExhibits); delete[] this->exhibits; this->exhibits = newExhibits; this->exhibits[this->numExhibits] = std::move(exhibit); this->incrementNumExhibits(); } void Zoo::setCage(int cageNumber) { int *newCages = new int[static_cast(this->numCages + 1)]; std::copy(this->cages, this->cages + static_cast(this->numCages), newCages); delete[] this->cages; this->cages = newCages; this->cages[this->numCages] = cageNumber; this->incrementNumCages(); } std::string *Zoo::getExhibit(std::size_t exhibitIndex) { return &this->exhibits[exhibitIndex]; } int *Zoo::getCage(std::size_t cageIndex) { return &this->cages[cageIndex]; } int Zoo::getNumExhibits() const { return this->numExhibits; } int Zoo::getNumCages() const { return this->numCages; } void Zoo::incrementNumExhibits() { this->numExhibits += 1; } void Zoo::incrementNumCages() { this->numCages += 1; } } // namespace zoo