T
tomo
Let's say i have this example
public interface Caclucation{
public int calculateTax1(int a, int b, int c);
public int clalcuateTax2(int a, int b);
}
class ConcreteOne implements Calculation{
public int calculateTax1(int a, int b, int c){
return a+b+c;
}
public int calculateTax2(int a, int b){
return a+b;
}
}
class ConcreteTwo implements Calculation{
public int calculateTax1(int a, int b, int c){
return a+b-c;
}
public int calculateTax2(int a, int b){
return a+b;
}
}
So I have two different strategies, but calculateTax2 method is the same for
both od them ? How can I avoid this ? And if i have many methods that are
same in the first and second class is there a
way to put them to some common class ? whould that be a violation on the
strategy pattern ?
Thanks.
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4482 (20091005) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
public interface Caclucation{
public int calculateTax1(int a, int b, int c);
public int clalcuateTax2(int a, int b);
}
class ConcreteOne implements Calculation{
public int calculateTax1(int a, int b, int c){
return a+b+c;
}
public int calculateTax2(int a, int b){
return a+b;
}
}
class ConcreteTwo implements Calculation{
public int calculateTax1(int a, int b, int c){
return a+b-c;
}
public int calculateTax2(int a, int b){
return a+b;
}
}
So I have two different strategies, but calculateTax2 method is the same for
both od them ? How can I avoid this ? And if i have many methods that are
same in the first and second class is there a
way to put them to some common class ? whould that be a violation on the
strategy pattern ?
Thanks.
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4482 (20091005) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com