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
|
class Animal {
public:
enum species_t {LION, FOX, RAVEN, HAWK, TETRA, SALMON}; //stores different species
enum gender_t {MALE, FEMALE}; //stores different genders
//default constructor
Animal() {
}
//overloaded constructor
Animal(species_t species, gender_t gender, int age) {
}
//create getInfo funcs???
bool inHeat(vector<Animal>& animals) {
for (Animal& ani : animals) {
if ((ani.species() == Animal::SALMON || ani.species() == Animal::TETRA) && ani.gender() == Animal::FEMALE) {//checks for fish & female
if (months % 6 == 0 && months != 0) { //checks to see if fish is in heat
return true;
}
}
if ((ani.species() == Animal::HAWK || ani.species() == Animal::RAVEN) && ani.gender() == Animal::FEMALE) {//checks for bird & female
if (months % 9 == 0 && months != 0) { //checks to see if bird is in heat
return true;
}
}
if ((ani.species() == Animal::FOX || ani.species() == Animal::LION) && ani.gender() == Animal::FEMALE) {//checks for mammal & female
if (months % 12 == 0 && months != 0) { //checks to see if mammal is in heat
return true;
}
}
return false;
}
}
void ageUp(const vector<Animal>& animals) {
for (const Animal& ani : animals) {
//add 1 month to all ages
}
}
species_t species() const noexcept {
return species;
}
gender_t gender() const noexcept {
return gender;
}
int age() const noexcept {
return age;
}
private:
int age = 0, months = 11;
species_t species = LION;
gender_t gender = MALE;
};
int main() {
vector<Animal> animals{ Animal(Animal::LION, Animal::FEMALE, 11), //the first 12 animals @ starting ages of 11 mths
Animal(Animal::LION, Animal::MALE, 11),
Animal(Animal::FOX, Animal::FEMALE, 11),
Animal(Animal::FOX, Animal::MALE, 11),
Animal(Animal::HAWK, Animal::FEMALE, 11),
Animal(Animal::HAWK, Animal::MALE, 11),
Animal(Animal::RAVEN, Animal::FEMALE, 11),
Animal(Animal::RAVEN, Animal::MALE, 11),
Animal(Animal::TETRA, Animal::FEMALE, 11),
Animal(Animal::TETRA, Animal::MALE, 11),
Animal(Animal::SALMON, Animal::FEMALE, 11),
Animal(Animal::SALMON, Animal::MALE, 11) };
return 0;
}
|