工厂方法模式
来源:互联网 发布:中国大数据信息 编辑:程序博客网 时间:2024/06/07 20:44
package com.lantier.xxb_student.drawlayerlayout.factory;/** * Created by xxb_student on 2017/5/20. */public abstract class Factory { public abstract WindowStyle createWindowStyle();}
package com.lantier.xxb_student.drawlayerlayout.factory;/** * Created by xxb_student on 2017/5/20. */public class MacThemeFactory extends Factory { @Override public WindowStyle createWindowStyle() { return new MacWindowStyle(); }}
package com.lantier.xxb_student.drawlayerlayout.factory;import android.util.Log;/** * Created by xxb_student on 2017/5/20. */public class MacWindowStyle extends WindowStyle { private static final String TAG = "MacWindowStyle"; @Override public void useThisStyle() { Log.d(TAG, "---->>useThisStyle:MacWindowStyle "); }}
package com.lantier.xxb_student.drawlayerlayout.factory;import android.util.Log;/** * Created by xxb_student on 2017/5/20. */public class UbuntuWindowStyle extends WindowStyle { private static final String TAG = "UbuntuWindowStyle"; @Override public void useThisStyle() { Log.d(TAG, "---->>useThisStyle:UbuntuWindowStyle "); }}
package com.lantier.xxb_student.drawlayerlayout.factory;/** * Created by xxb_student on 2017/5/20. */public abstract class WindowStyle { public abstract void useThisStyle();}
package com.lantier.xxb_student.drawlayerlayout.factory;import android.util.Log;/** * Created by xxb_student on 2017/5/20. */public class WindowsWindowStyle extends WindowStyle { private static final String TAG = "WindowsWindowStyle"; @Override public void useThisStyle() { Log.d(TAG, "---->>useThisStyle: WindowsWindowStyle"); }}
private void init() { Factory factory = new MacThemeFactory(); WindowStyle windowStyle = factory.createWindowStyle(); windowStyle.useThisStyle();}
05-20 15:06:04.610 1197-1197/com.lantier.xxb_student.drawlayerlayout D/MacWindowStyle: ---->>useThisStyle:MacWindowStyle
阅读全文
0 0
- 工厂模式 -- 工厂方法
- 工厂模式-工厂方法
- 工厂模式-工厂方法
- 工厂 > 工厂方法模式
- 工厂模式-工厂方法模式
- 工厂模式-工厂方法模式
- 工厂模式---工厂方法模式
- 【模式】工厂方法模式
- 工厂方法,抽象工厂模式
- C#工厂模式-工厂方法
- 工厂模式 和工厂方法
- 工厂模式-C-工厂方法
- 工厂模式以及工厂方法
- 简单工厂、工厂方法、抽象工厂模式
- 简单工厂、工厂方法、抽象工厂模式
- 工厂模式(简单工厂、工厂方法)
- 简单工厂|工厂方法|抽象工厂模式
- 设计模式-工厂模式(简单工厂模式+工厂方法模式)
- 点击按钮 “加载更多”效果
- There's no Qt version assigned to this project for platform x64
- Xutils简单介绍
- 网络基础之协议-1
- java设计模式——迭代器模式
- 工厂方法模式
- 所谓IIS500内部服务器错误
- MyBatis动态SQL<choose>标签的使用
- Unity Leap Motion学习笔记
- Eclipse中Ctrl+Shift+F代码格式化快捷键失效的解决方法
- Java配置maven+jenkins+git(svn)+tomcat自动编译和部署(持续集成)
- 一步一步写miscdevice的驱动模块
- getchar()无用
- DOM 的一些常用方法