I have an abstract class Detail, and four classes Rock, Grass, Tree, and Bush which extend Detail.
Tree and Bush have a Fruit property, but the others do not
I have a Detail[] which contains all 4 types of detail, and given an index I need to find that detail's fruit, if it has any.
I don't want to put the Fruit property in the base class Detail because not all details have fruit, and different kinds of detail have entirely different properties.
How can I get the Fruit of, for example, Detail[17] without knowing what kind of detail it is beforehand, or whether it has fruit (perhaps returning null if there is none)? Keeping in mind there will be possibly hundreds of different types of details with dozens of possible properties.
I'm imagining some kind of tagging system where each item in the array may or may not have one of several tags, but this is the closest I've managed so far.