1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
// platypus.h
//
#ifndef PLATYPUS_H
#define PLATYPUS_H
#include <random>
#include <string>
#include <utility>
/** A platypus */
class Platypus {
private:
/** The platypus' name */
std::string name;
/**
* @brief The platypus' gender
*
* Restricted to 'm' or 'f'
*
*/
std::string gender;
/** The platypus' weight */
float weight;
/** The platypus' age in months */
short int age;
/** The platypus' alive state */
bool alive;
/** The platypus' mutant state */
bool mutant;
public:
/**
* @brief A dead platypus
* @author Ricky
*/
Platypus(); // dead platypus
/**
* @brief A platypus with a custom state
* @authors Ricky and Zoltan
*/
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, Ricky and Zoltan
/** 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, Ricky and Zoltan
/** 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; }
// Ricky
/**
* @brief Print out a platypus
*/
void print();
/**
* @brief Ages the platypus by one
* @author Zoltan
*
* 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
* @author Ricky
*
* 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.
* @author Zoltan
*
*/
void eat();
/**
* @brief Birth a new platypus with a random (alive, not mutant) state
* @author Zoltan
*
* If the current platypus is not alive, `hatch`ing will
* return an uninitialized platypus.
*
* @return Platypus
*/
Platypus hatch() const;
};
#endif // PLATYPUS_H
|