But inheritance/polymorphism is only the smaller part...
If you want to give an object an attribute (such as color), inheritance is not the right way.
With the colored cubes on the right, this would lead to a high number of classes.
Inheritance says “This object is (a special form of) another object.”
We want to look at another technique now, the association.
Association says “This object has / uses / contains another object”
Here: “our cube (or, any body for that matter) has a color.”
If you have n different classes and m different attributes, using inheritance would yield n * m resulting classes if you want to provide all possibilities. If you have another attribute (say, flavor), with k possibilities, you get n * m * k resulting classes. This can easily lead to an extremely high number of classes.
Inheritance is static, while associations are dynamic. If color is a property of the class as in the cartoon, you cannot change the color except by deleting the object and creating a new one. But if “color” is just an attribute, you can change it easily for an existing object. The associaton technique lets you combine attributes like you shop for a car: you choose a base model and then you can decide on color, sunroof, radio, interior, tires, etc. You can also change attributes (“which radio”) at any time by just replacing it.