this statement asks me what kind of design pattern applied, firstly , tell me what to build toys, as they are only 3 types of play, and none is related eg with some color, would apply the factory method.
But apart it tells me that the Toys can be turned off and on, which makes me think that this would be a command pattern (or state).
I can mix 2 patterns in a final solution?
We want to build 3 kinds of toys : Pokemon , Barbie and Superman . They feature animation actions associated with their off and on , these actions are different for each type of toy. Explain what design pattern and would use the class diagram Perform final design .
thanks
You can mainly take the approach of using the 'Abstract Factory Pattern'.
This is how you should do the implementation
Declare an interface ShowAnimation
Then inside each of your Pokemon , Barbie and Superman classes, you will simply implement this ShowAnimation interface and override the onState and offState methods as per your business logic. This way
This entire pattern you term as Abstract Factory Design Pattern.
Follow this link for more reference http://www.tutorialspoint.com/design_pattern/abstract_factory_pattern.htm
Edit 1- I would like to update my answer "This is the Command Pattern that you will use using an interface and implementing the interface, however, you can create a separate abstract class Toys
and make other concrete class Barbie to extend Toys and implement ShowAnimation
So, basically you can mix both 'Factory Pattern' as well as 'Command Pattern' to achieve this.