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("不支持的支付方式"); } } }