Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement