摘要:
模板方法: 定义一个操作的算法骨架,而将一些步骤延迟到子类中。Template Method 使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤。 /** * 模板方法模式 */ public class TemplateMethod { public static void main( 阅读全文
posted @ 2021-05-20 22:29
炼金术士0z
阅读(41)
评论(0)
推荐(0)
摘要:
策略模式: 定义了算法族,分别封装起来,让它们之间可以相互替换,此模式的变化独立于算法的使用者。 /** * 策略模式 */ public class Stragety { public static void main(String[] args) { Zombie normalZombie = 阅读全文
posted @ 2021-05-20 22:08
炼金术士0z
阅读(48)
评论(0)
推荐(0)
摘要:
装饰者模式: 在不改变原有对象的基础上,将功能附加到对象上 /** * 装饰者模式 */ public class decoratorTest { public static void main(String[] args) { Component component = new ConcreteD 阅读全文
posted @ 2021-05-20 00:16
炼金术士0z
阅读(45)
评论(0)
推荐(0)

浙公网安备 33010602011771号