最近学习了《大话设计模式》,写出关键代码总结一下~
1、简单工厂模式
public Class OperationFactory {
public static Operation createOperate(String operate) {
Operation oper = null;
switch (operate) {
case ?:
oper = ...
break;
......
}
return oper;
}
}
2.策略模式
Demo:
3.装饰模式
4.
最近学习了《大话设计模式》,写出关键代码总结一下~
public Class OperationFactory {
public static Operation createOperate(String operate) {
Operation oper = null;
switch (operate) {
case ?:
oper = ...
break;
......
}
return oper;
}
}
Demo:
4.