Skip to content

Instantly share code, notes, and snippets.

@sahoosunilkumar
Last active March 18, 2019 05:21
Show Gist options
  • Save sahoosunilkumar/bd2c52a3141193735f98691a4e941b00 to your computer and use it in GitHub Desktop.
Save sahoosunilkumar/bd2c52a3141193735f98691a4e941b00 to your computer and use it in GitHub Desktop.
PaymentFactoryMethod implementation
public class PaymentFactoryMethod {
public static IPayment createPayment(PaymentType type) {
IPayment payment = null;
switch (type) {
case PAYTM:
payment = new PaytmPayment();
break;
case GOOGLEPAY:
payment = new GooglePayPayment();
break;
case PAYPAL:
payment = new PaypalPayment();
break;
default:
payment = new PaytmPayment();
break;
}
return payment;
}
}
public enum PaymentType {
PAYTM, GOOGLEPAY, PAYPAL
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment