Mid SOLID

How do you apply Strategy pattern to implement multiple payment methods?

Define a common interface, e.g., IPaymentStrategy with a method Pay(). Implement

concrete strategies for each payment method (CreditCard, PayPal, etc.). Use a context class

to invoke the selected strategy at runtime, enabling easy extension without modifying

existing code.

More from Design Patterns in C#

All questions for this course