Wednesday, April 6, 2005 05:49 PM
You can go for factory pattern. Create a factory called MusicFactory and it should have method called getMusicFactory , which should return either ColorPanel or NonColorPanel class while passing an colorType argument. But you should able to identiy whether the request is Color or NonColor , then you can able to initialize the appropriate class.
Or you can go for AbstractFactory pattern that create a common class called Music which has all the basic functionality of ColorPanel and NonColorPanel. And you can create a very specific class for ColorPanel and NonColorPanel, these class has to implements Music class.
For both the Pattern you have to identify the request first Color or NonColor.