diff options
Diffstat (limited to 'platypus/platypus.h')
| -rw-r--r-- | platypus/platypus.h | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/platypus/platypus.h b/platypus/platypus.h new file mode 100644 index 0000000..3e9ce2b --- /dev/null +++ b/platypus/platypus.h @@ -0,0 +1,108 @@ +// platypus.h +// + +#ifndef PLATYPUS_H +#define PLATYPUS_H +#include <random> +#include <string> +#include <utility> + +/** A platypus */ +class Platypus { +private: + /** The platypus' weight */ + float weight; + /** The platypus' age in months */ + short age; + /** The platypus' alive state */ + bool alive; + /** The platypus' mutant state */ + bool mutant; + /** The platypus' name */ + std::string name; + /** + * @brief The platypus' gender + * + * Restricted to 'm' or 'f' + * + */ + std::string gender; + +public: + /** A dead platypus */ + Platypus(); // dead platypus + /** A platypus with a custom state */ + Platypus(float _weight, short _age, std::string _name, std::string _gender) + : weight(_weight), age(_age), alive(true), mutant(false), + name(std::move(_name)), gender(std::move(_gender)) { + srand(static_cast<unsigned int>(time(nullptr))); + rand(); + } // constructor that you can pass values to so as to + // establish + // ~Platypus() {} + + // Setters + /** Mutate the platypus' weight */ + void setWeight(float _weight) { weight = _weight; } + /** Mutate the platypus' age */ + void setAge(short _age) { age = _age; } + /** Mutate the platypus' name */ + void setName(std::string _name) { name = std::move(_name); } + /** Mutate the platypus' gender */ + void setGender(std::string _gender) { gender = std::move(_gender); } + /** Mutate the platypus' alive state */ + void setAlive(bool _alive) { this->alive = _alive; } + /** Mutate the platypus' mutant state */ + void setMutant(bool _mutant) { this->mutant = _mutant; } + + // Getters + /** Get the platypus' weight */ + float getWeight() const { return weight; } + /** Get the platypus' age */ + float getAge() const { return age; } + /** Get the platypus' name */ + std::string getName() { return name; } + /** Get the platypus' gender */ + std::string getGender() { return gender; } + /** Get the platypus' alive state */ + bool getAlive() const { return this->alive; } + /** Get the platypus' mutant state */ + bool getMutant() const { return this->mutant; } + + void print(); + /** + * @brief Ages the platypus by one + * + * The platypus has a 2% chance of becoming mutant. + * + * The platypus has a (50% + its weight) chance of death. + * + */ + void ageMe(); + /** + * @brief Fight another platypus + * + * The platypus has a ((platypus / aggressor) * 50) chance of death where the + * platypus survives if a random number between one and one-hundred resolves + * to greater than the chance of death. + * + */ + void fight(Platypus &); + /** + * @brief Increases the weight of the platypus by the a random percent between + * 0.1 and 5.0 of the current weight. + * + */ + void eat(); + /** + * @brief Birth a new platypus with a random (alive, not mutant) state + * + * If the current platypus is not alive, `hatch`ing will + * return an uninitialized platypus. + * + * @return Platypus + */ + Platypus hatch() const; +}; + +#endif // PLATYPUS_H |