// filename: testPlatypus.cpp // summary: print out the paltypus #include "platypus.h" #include using namespace std; // The testing suite is pretty much 50-50 between us. (Ricky and Zoltan) int main() { // Test `Platypus` constructors, setters, getters, `eat`ing, aging, and // `print`ing { // Test constructors Platypus p1; Platypus p2(23.5, 5, "Perry", "m"); Platypus p3(2, 3, "Pearl", "f"); std::cout << "Platypus #1 after birth(default constructor):\n" << std::endl; // Test `print` p1.print(); std::cout << "\nPlatypus #3 after birth(established constructor):\n" << std::endl; p3.print(); // Test setters p1.setWeight(25.7f); p1.setAge(4); p1.setName("Optimus"); p1.setGender("m"); p1.setAlive(true); p1.setMutant(false); std::cout << "\nPlatypus #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() << "\n\nPlatypus #1 before aging: " << p1.getAge() << ", old mutant status: " << p1.getMutant() << ", old alive status: " << p1.getAlive() << "\nPlatypus #3 before aging: " << p3.getAge() << ", old mutant status: " << p3.getMutant() << ", old alive status: " << p3.getAlive() << endl; // Test aging p1.ageMe(); p3.ageMe(); cout << "\nPlatypus #1 after aging: " << p1.getAge() << ", new mutant status: " << p1.getMutant() << ", new alive status: " << p1.getAlive() << '\n' << "Platypus #3 after aging: " << p3.getAge() << ", new mutant status: " << p3.getMutant() << ", new alive status: " << p3.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; }