EveryThings EatMe(theObjThatEatsMe) > |- LivingThings FeedMe(theObjFed), WaterMe(theObjWatered) > | |- Person > | |- Cow > | |- Nightshade > |- NonLivingThings > | - Cake>How do you know what's edible? I guess EatMe() will contain all logic you'd have in all interface implementations:
local llRetVal >llRetval = .F. >if this is a Nightshade > if theObjThatEatsMe is a Person that is not suicidal > llRetval = .F. > else > llRetval = .T. > endif >else > llRetval = .T. >endif >if this is a Cow > if theObjThatEatsMe is a Person that is vegetarian > llRetval = .F. >... >What if you have a dozen or so other farm animals as well as a Cow (Sheep,chicken, rabbit etc) Aren't you then going to have to change your code to 'If this is a cow or this is a chicken or this is a rabbit... ' (and change it every time you add another edible lifeform. So much easier to implement interfaces such a IEdible,INeedsWatering etc. and apply them the the relevant classes: