设计模式----策略模式
来源:互联网 发布:badusb淘宝 编辑:程序博客网 时间:2024/06/07 01:13
1.直接上代码,注释很详细
interface celue{ //先创建策略的接口 void celuefangfa();}class celue1 implements celue{ //创建策略1 @Override public void celuefangfa() { Log.e("","策略1"); }}class celue2 implements celue{ //创建策略2 @Override public void celuefangfa() { Log.e("","策略2"); }}class celue3 implements celue{ //创建策略3 @Override public void celuefangfa() { Log.e("","策略3"); }}class CLShitianzhuang{ //策略装进去 public CLShitianzhuang(celue celue) { //只要传入某个策略 celue.celuefangfa(); } //将策略填装进去}class CLShiyongzhe { public CLShiyongzhe() { CLShitianzhuang cl=new CLShitianzhuang(new celue1()); //使用策略1 CLShitianzhuang c2=new CLShitianzhuang(new celue2()); //使用策略2 CLShitianzhuang c3=new CLShitianzhuang(new celue3()); //使用策略3 }}
1 0
- 设计模式-策略模式
- 设计模式:策略模式
- 设计模式-策略模式
- 设计模式 - 策略模式
- 设计模式-策略模式
- 设计模式-----策略模式
- 设计模式 策略模式
- 设计模式-策略模式
- 设计模式-【策略模式】
- 设计模式-----策略模式
- 设计模式-策略模式
- 设计模式--策略模式
- 设计模式- 策略模式
- 设计模式- 策略模式
- 设计模式------策略模式
- 设计模式--策略模式
- 设计模式-策略模式
- 设计模式--策略模式
- mongoDBChef连接不上CentOS上的mongodb
- [docker]你不知道的docker奇淫技巧
- 进程管理(上)
- ActivityLifecycleCallbacks
- rex 使用ssh认证
- 设计模式----策略模式
- FreeMarker模板继承
- 进程和线程的区别收藏
- 系统吞吐量(TPS)、用户并发量、性能测试概念和公式
- linux下创建svn版本库
- JAVA集合类基础特性
- main主函数执行完毕后,是否会再执行一段代码?
- java List集合分页
- 5.12号学习日志