summaryrefslogtreecommitdiff
path: root/platypus/testPlatypus.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platypus/testPlatypus.cpp')
-rw-r--r--platypus/testPlatypus.cpp101
1 files changed, 101 insertions, 0 deletions
diff --git a/platypus/testPlatypus.cpp b/platypus/testPlatypus.cpp
new file mode 100644
index 0000000..7085545
--- /dev/null
+++ b/platypus/testPlatypus.cpp
@@ -0,0 +1,101 @@
+// filename: testPlatypus.cpp
+// summary: print out the paltypus
+
+#include "platypus.h"
+#include <iostream>
+using namespace std;
+
+int main() {
+ // Test `Platypus` constructors, setters, getters, `eat`ing, aging, and
+ // `print`ing
+ {
+ // Test constructors
+ Platypus p1;
+ Platypus p2(23.5, 5, "Perry", "m");
+
+ std::cout << "Platypus #1 after birth(default constructor):\n" << std::endl;
+
+ // Test `print`
+ p1.print();
+
+ cout << endl;
+
+ // Test setters
+ p1.setWeight(25.7f);
+ p1.setAge(4);
+ p1.setName("Optimus");
+ p1.setGender("m");
+ p1.setAlive(true);
+ p1.setMutant(false);
+
+ std::cout << "Platypus #1 after changes to weight, age, name, gender, "
+ "alive, mutant:\n"
+ << std::endl;
+
+ p1.print();
+
+ // Test getters
+ cout << "\nPlatypus #1 weight before eating: " << p1.getWeight() << endl;
+
+ // Test `eat`ing
+ p1.eat();
+
+ cout << "Platypus #1 weight after eating: " << p1.getWeight() << endl;
+
+ cout << "\nPlatypus #1 before aging: " << p1.getAge()
+ << ", old mutant status: " << p1.getMutant()
+ << ", old alive status: " << p1.getAlive() << endl;
+
+ // Test aging
+ p1.ageMe();
+
+ cout << "Platypus #1 after aging: " << p1.getAge()
+ << ", new mutant status: " << p1.getMutant()
+ << ", new alive status: " << p1.getAlive() << endl
+ << endl;
+ }
+
+ // Test `Platypus` `fight`ing and `hatch`ing
+ {
+ Platypus p1(22.8f, 4, "John", "m");
+ Platypus p2(23.5, 5, "Perry", "m");
+
+ std::cout << "New platypus #1 before fight:\n" << std::endl;
+
+ p1.print();
+
+ std::cout << "\nPlatypus #2 before fight:\n" << std::endl;
+
+ p2.print();
+ // Test `fight`
+ p1.fight(p2);
+
+ std::cout << "\nNew platypus #1 after fight:\n" << std::endl;
+
+ p1.print();
+
+ std::cout << "\nPlatypus #2 after fight:\n" << std::endl;
+
+ p2.print();
+
+ std::cout << "\nPlatypus #3 hatched a platypus:\n" << endl;
+
+ // Test hatch
+ Platypus p3(1, 2, "Becky", "f");
+ Platypus hatched = p3.hatch();
+
+ hatched.print();
+
+ if (hatched.getWeight() < 1e-8f) {
+ std::cout << "\nThe hatched platypus looks to be dead, since the "
+ "platypus birthing it was dead too."
+ << std::endl;
+ }
+
+ std::cout << "\nJust to test `getName` and `getGender` here's the name and "
+ "gender of the hatched platypus: "
+ << hatched.getName() << ", " << hatched.getGender() << std::endl;
+ }
+
+ return 0;
+}