CarModel and Car that extends CarModel. Where CarModel is the model of the car and the Car is the concrete instance of a car model (witht the VIN, owner and so on….).
I also have some other classes that contain references to CarModel, so i need to have the CarModel as a separate object instances in database and the Car should point to the data from the car model.
How can i implement the Car so when it is instantiated - it automatically loads the data from the CarModel instance that it extends?
To precise - i know that this can be easily implemented with object containment instead of inheritance, but for me the logic is that the Car is a CarModel and there are some places where i need to use polymorphism.
Thanks to anyone in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello All,
I have this two classes:
CarModel and Car that extends CarModel. Where CarModel is the model of the car and the Car is the concrete instance of a car model (witht the VIN, owner and so on….).
I also have some other classes that contain references to CarModel, so i need to have the CarModel as a separate object instances in database and the Car should point to the data from the car model.
How can i implement the Car so when it is instantiated - it automatically loads the data from the CarModel instance that it extends?
To precise - i know that this can be easily implemented with object containment instead of inheritance, but for me the logic is that the Car is a CarModel and there are some places where i need to use polymorphism.
Thanks to anyone in advance