summaryrefslogtreecommitdiff
path: root/src/Zoo.cc
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-06-09 22:10:55 -0700
committerFuwn <[email protected]>2022-06-09 22:10:55 -0700
commit3f07f307569afce65e0ed96499e344f8c2656198 (patch)
tree0a8938ebd967d575678ddd3c83c206074331ca2b /src/Zoo.cc
downloadzoo-main.tar.xz
zoo-main.zip
feat: initial commitHEADmain
Diffstat (limited to 'src/Zoo.cc')
-rw-r--r--src/Zoo.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/Zoo.cc b/src/Zoo.cc
new file mode 100644
index 0000000..41d4ea3
--- /dev/null
+++ b/src/Zoo.cc
@@ -0,0 +1,55 @@
+#include <algorithm>
+#include <utility>
+
+#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<unsigned long>(this->numExhibits + 1)];
+
+ std::copy(this->exhibits,
+ this->exhibits + static_cast<unsigned long>(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<unsigned long>(this->numCages + 1)];
+
+ std::copy(this->cages,
+ this->cages + static_cast<unsigned long>(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