mirror of
https://github.com/Dichgrem/Java.git
synced 2025-12-17 04:51:58 -05:00
update:demo4
This commit is contained in:
16
com/study/demo4/PaymentFactory.java
Normal file
16
com/study/demo4/PaymentFactory.java
Normal file
@@ -0,0 +1,16 @@
|
||||
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("不支持的支付方式");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user