【策略模式】实例——工资支付
文章目录前言一、题目描述二、设计步骤1.上下文传参实现2.扩展上下文总结前言一、题目描述用多种支付方式实现工资的分发(如人民币支付、美金支付)。使用上下文对象传递和扩展上下文传递二、设计步骤1.上下文传参实现代码如下(示例)://工资支付接口interface PaymentStrategy{ public void pay(PaymentContext ctx);}//人民币现金支付class RMBCash implements PaymentStrategy{ publ