Currently I have 3 classes in which most of the variables are same. All the variables have getter and setter. I need to create the object of the class based on the datatype variable Year provided and pass that object in the more than ten methods. Lets Take a Example.
We have three Classes ClassA,ClassB,ClassC. If we pass the year 2017 then i need the object of ClassA. If we pass the year 2016 then i need the object of ClassB and for all other year we need the object of ClassC.
Then after we need to pass that object in the all 10 Methods. Let take an exmaple of 2 methods.
public void method1(int a, int b, object of classA/B/C).
public void method2(int a, int b, object of classA/B/C).
Both the methods working on the object and setting some variable in object.
But one problem is that i don't want to extend class or implement interface in the ClassA,ClassB,ClassC.
Please let me know the Design Pattern that perfect for my requirement.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire