Considering the java example for strategy pattern:
If we have a new customer type e.g. MemberCustomer who can also be charged in terms of loyalty points. The billing strategy may change for normal or happy hours as follows:
int NormalStrategyForMemberCustomer{
int getActPrice(int loyaltyPoints){
return loyaltyPoints;
}
}
int HappyHoursStrategyForMemberCustomer{
int getActPrice(int loyaltyPoints){
return loyaltyPoints/2;
}
}
In this case should I create the above methods as new strategies and inherit a new class from Customer class as MemberCustomer and try to fit the strategy pattern?
Or is there another design pattern which fits better here?
Aucun commentaire:
Enregistrer un commentaire