策略模式
来源:互联网 发布:安卓版本 知乎 编辑:程序博客网 时间:2024/05/17 18:14
public class Zhaoyun { public static void main(String[] args) { Test test=new Test(new FirstSgy()); test.operation(); test.setSgy(new SecondSgy()); test.operation(); test.setSgy(new ThirdSgy()); test.operation(); }}interface Isgy{ public void operation();}class FirstSgy implements Isgy{ public void operation(){ System.out.println("第一条妙计"); }}class SecondSgy implements Isgy{ public void operation(){ System.out.println("第二条妙计"); }}class ThirdSgy implements Isgy{ public void operation(){ System.out.println("第三条妙计"); }}class Test{ private Isgy sgy; public Test(Isgy sgy) { super(); this.sgy = sgy; } public Isgy getSgy() { return sgy; } public void setSgy(Isgy sgy) { this.sgy = sgy; } public void operation(){ sgy.operation(); }}
阅读全文
0 0
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 策略模式
- 厚积薄发---从此再也不用担心闭包问题
- 23种设计模式
- 最优化方法
- puppet 简单的安装及配置
- Struts2(六)---OGNL
- 策略模式
- Digit-Sum HDU
- 创建一个简单的ModelValidator
- Qt Project ERROR: Cannot run compiler 'cl'
- android 屏幕保持唤醒 不锁屏 android.permission.WAKE_LOCK
- React Native的环境搭配
- kylin 优化
- jqgrid(使用一)
- Spark Learning(RDD介绍)