SHARE
TWEET

Untitled

a guest Mar 21st, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top