You could implement a class factory that creates the correct instances based on the age.
How to create instances of subclasses based on the value of a super class attribute
-
09-06-2023 - |
Pergunta
I have a super class Person with a private attribute age, I want to have subclasses Baby, Adult, Old and instances of these classes are created based on the age of the Person..How do I do this ?
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow