its up to you. KISS suggests you just have your class be critter-type, critter-age, critter-gender, and anything else you need and have a single container of those. you can sort it by type to iterate the breeding easier. Since you can use age, you can resort it to have then printed by their creation date/oldest first at the end.
a vector of those sounds great.
its a vector of animal class. no need for pointer nonsense. **
1 2 3 4 5 6 7 8 9
|
enum animal_types {invalid, dog, cat, shark, goldfish, ...}
class animal
{
animal_types mytype{}; //invalid default
unsigned int age{};
char gender{}; //'m' and 'f' or 0,1 or whatever anything goes here even strings of "male" "female" 0 is invalid assumed for the {} default,
//if you use 0,1 then {42} initialize can be invalid marker.
};
vector<animal> ark_inventory;
| |
**ok, off the deep end of the pool, it can be useful here to have multiple vectors of pointers to sort the data, eg a vector sorted by age and another by type (and then by gender)
sorting pointers is much, much faster than sorting fat objects. If you had billions of them and ran the sim for 5000 years or something, ok, we can go over all that. Its not going to be a big deal for a classroom assignment on a modern computer to do a few thousand critters in a fraction of a second.
a question now is what kind of methods you need.
you need something to age all the critters.
you need something to print them out.
you need something to 'breed' them based off your rules. The % operator can tell you if something that is 27 months old should be breeding or not... 27%9 is zero, its time for a bird to breed, but 27%6 is not, a fish would not be ready... (that isnt quite right, you don't want to breed on day 0/right away, but the % will help you when you get to that part)