mirror of
https://github.com/Dichgrem/Java.git
synced 2025-12-16 12:41:58 -05:00
17 lines
416 B
Java
17 lines
416 B
Java
package com.study.demo4;
|
|
|
|
class PaymentFactory {
|
|
public static PaymentProcessor getProcessor(String type) {
|
|
switch (type.toLowerCase()) {
|
|
case "wechat":
|
|
return new WechatPayment();
|
|
case "alipay":
|
|
return new AlipayPayment();
|
|
case "card":
|
|
return new CreditCardPayment();
|
|
default:
|
|
throw new IllegalArgumentException("不支持的支付方式");
|
|
}
|
|
}
|
|
}
|