[contest] Is a Cow an animal ++

retard re at tard.com.invalid
Tue Sep 28 07:07:34 PDT 2010


Mon, 27 Sep 2010 22:06:18 -0400, bearophile wrote:

> Simen kjaeraas:
>> Here's mine ( 8/11 at compile-time, the remaining at runtime ):
>> http://ideone.com/6WlFJ
> 
> Thank you. It's a nice implementation, and it doesn't use template magic
> at all, it's fully OOP :-) Your implementation shows that there are many
> different ways to solve this puzzle. I presume a bit shorter code is
> possible using templates (as in the 4th C++ version).
> 
> I have modified your code a little, I have added the missing 'override',
> I have added the required sequence ("there should be a way to handle a
> list of animals and the energy of each animal"), but there is no need
> for the name field because there is the classinfo.name, and I have
> shortened/simplified your (nice) test code a lot:
> http://ideone.com/TQzyD

One of the requirements is:

"animals can eat some food, their energy is raised by the food's energy 
amount"

However, the eat method seems not to be part of the animal class in your 
code. Admittedly this is hair-splitting.


More information about the Digitalmars-d mailing list