posted 17 years ago
Thanks, continuing from above, I need the Factory to create Shape (an Interface) objects, such as Circle,Triangle,Rectangle(implements Shape).
But the Constructor for Circle takes one argument, the radius.
The constructor for Triangle and Rectangle take 2, base and height.
So in my Singleton Factory class, I have the method:
So to create a Circle radius 8:
So you can see I'm passing an array of parameters in since this is variable( 1 or 2 parameters).
This is probably not the best approach, I have thought about subclassing the SingletonFactory to give two classes, one that deals with objects that require 1 parameter passed in, and one that deals with objects that require 2 parameters passed in.
Is this a good idea, or is there a better way to pass in the parameters to the factory to produce specific sized shapes?
Thanks for help.