It's difficult to comment on the design because it seems like you're just testing things out without any real requirements about what the program is actually supposed to do.
In a real program the requirements would influence the design and if the requirements changed then you might also have to change the design.
For example, in a simple console game it might be enough to call a single function to handle the act of "eating" but in a graphical game "eating" might be a much more complicated process because it involves playing an animation and possibly sound. It doesn't just happen all at once but instead it happens over a period of time and it might happen at the same time as other things are going on. It might even be possible for some actions to interrupt the "eating" (e.g. if the player or some other animal attacks).
------------------------------
I notice you use
std::cout quite a lot. In a real program I wouldn't expect it to be used quite so frequently.
Is the purpose of the function to return a value or do something other than printing? In that case I wouldn't normally expect it to print anything.
To me it seems a bit inconvenient to have the Increment and Decrement functions (sometimes) print something.
You have written the following line:
|
std::cout << GetName() << " ate some food and gained -" << DecrementHunger(1) << " hunger!\n";
|
Imagine if
DecrementHunger(1) printed something (which it will if the hunger reach zero). Then it wouldn't print what you expected, would it?
You might see something like:
Bessie ate some food and gained -Bessie is not hungry.
0 hunger! |
Another function I wouldn't expect to print anything is IsNull. I'm not even sure what the purpose of this function is when you can just compare the pointer directly.
1 2
|
if (IsNull(animal) == false)
if (animal != nullptr)
|