Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. public class PaymentFactoryMethod {
  2.  
  3. public static IPayment createPayment(PaymentType type) {
  4. IPayment payment = null;
  5.  
  6. switch (type) {
  7. case PAYTM:
  8. payment = new PaytmPayment();
  9. break;
  10. case GOOGLEPAY:
  11. payment = new GooglePayPayment();
  12. break;
  13. case PAYPAL:
  14. payment = new PaypalPayment();
  15. break;
  16. default:
  17. payment = new PaytmPayment();
  18. break;
  19.  
  20. }
  21. return payment;
  22.  
  23. }
  24.  
  25. }
  26.  
  27. public enum PaymentType {
  28. PAYTM, GOOGLEPAY, PAYPAL
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement