-
According to the Gang of Four Definitions, Strategy is a behavioral design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable.
-
The Strategy Design Pattern is a behavioral design pattern that defines a family of algorithms, encapsulates each one, and makes them interchangeable. It allows the algorithm to vary independently from clients that use it.
-
Create an interface with IPaymentStrategy
-
Create PaymentType Enum
-
CreditCardPaymentStrategy Concrete Strategy class implements the IPaymentStrategy Interface and provides implementations for the Pay Method.
-
CashCardPaymentStrategy Concrete Strategy class implements the IPaymentStrategy Interface and provides implementations for the Pay Method.
-
Create PaymentContext class that contains a property that holds the reference of a Strategy object. The client will set this property at run-time according to the payment option the client selected
-
Client code





