I have these classes: Imagine that for some reason, I need to make Car a superclass for two new classes: CombustionCar and ElectricCar. One of the new requierements is that ElectricCar’s brand attribute must be always TESLA value and not any of the other ones values. I’ve thougth some solutions: I could keep Brand attr on superclass Car, and make
Tag: composition
Why use inheritance at all? [closed]
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago.