문제

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 ?

도움이 되었습니까?

해결책

You could implement a class factory that creates the correct instances based on the age.

http://en.wikipedia.org/wiki/Factory_class

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top