by Azrael (4 Submissions)
Category: Object Oriented Programming (OOP)
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)
Probably useful if you want to learn about polymorphism, objects and collections. This is an example of polymorphism running out of control. 1000 generic Beast-class objects are created, each assigned to be either a Dog, Cat, or Mouse. Then, using calls to the Beast class, they try to eat each other, until only one (the biggest) remains. Try messing around with it ... a larger animal can only eat a smaller one, except in the case of mice who can eat an animal of the same size - it's only fair, they start so small.
Assumes
Nothing.
Code Returns
Nowt
Side Effects
None, unless I've inadvertently named one of the beasts after your pet and you're sensitive ... ;-)
Dogs nearly always win, by the way.