- 博客(20)
- 收藏
- 关注
原创 命令模式
class Program{ static void Main(string[] args) { Barbecuer boy = new Barbecuer(); Command bakeMuttonCommand1 = new BakeMuttonCommand(boy); Command bakeMuttonCommand2 = new Bake
2020-06-09 20:33:04 100
原创 职责链模式
public abstract class Manager {protected String name;protected Manager superior; //管理者的上级public Manager(String name) { this.name = name;}//设置管理者的上级public void setSuperior(Manager superior) { this.superior = superior;}//申请请求public abs
2020-06-09 20:29:07 105
原创 观察者模式
public class Subject {//观察者数组private Vector<Observer> oVector = new Vector<>();//增加一个观察者public void addObserver(Observer observer) { this.oVector.add(observer);}//删除一个观察者public void deleteObserver(Observer observer) { this.oVec
2020-06-03 08:12:57 90
原创 组合模式
public abstract class Component {23 protected String name;45 public Component(String name) {6 this.name = name;7 }89 //获取分支下的所有叶子构件和树枝构件10 public abstract void display(int depth);1112 }public class Composite extends
2020-06-03 08:03:13 113
原创 备忘录模式
public class GameRole {private int vitality;//生命力private int attack;//攻击力private int defense;// 防御力public int getVitality() {return vitality;}public void setVitality(int vitality) {this.vitality = vitality;}public int getAttack() {return attack;
2020-06-03 07:56:53 74
原创 模板模式
package muoban;abstract class mobanclass{abstract public void method1();public abstract void method2();public void templatemethod(){method1();method2();System.out.println(“finish”);}}class A extends mobanclass{@Overridepublic void method1() {
2020-05-12 20:07:48 82
原创 策略模式
package celue;interface Cash {public double acceptCash(double money);}class CashNormal implements Cash {@Overridepublic double acceptCash(double money) { return money;}}class CashRebate implements Cash {private double moneyRebate = 1;public
2020-05-12 19:48:45 77
原创 桥接模式
package sdfsfsd;interface Software { public void run();}class AppStore implements Software { @Override public void run() { System.out.println("run app store"); }}class Camera implement...
2020-04-28 20:13:36 123
原创 中介者模式
package sdfsfsd;//////////////////////////////////////////////////////////////////////////////////abstract class Mediator { public abstract void send(String message, Colleague colleague);}/...
2020-04-28 19:58:32 81
原创 代理模式
interface ITarget{void Request();}class Adaptee{public void SpecificRequest()System.out.println("特殊请求" );}class Adapter extends Adaptee implements ITarget{public void Request() {this....
2020-04-21 20:54:47 77
原创 外观模式
package dsf;class Fund{ stock1 gu1; stock2 gu2; stock3 gu3; nationaldebt1 nd1; reaty1 rt1;public Fund(){ gu1=new stock1(); gu2=new stock2(); gu3=new stock3(); nd1=n...
2020-04-21 20:46:05 96
原创 代理模式
class SchoolGirl{ private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }interface Givegift{ void GiveDolls();} ...
2020-04-21 20:28:52 84
原创 享元模式
package flyweight;import java.util.HashMap;public class FlyweightPattern{ public static void main(String[] args) { FlyweightFactory factory=new FlyweightFactory(); Flyweight...
2020-04-14 20:23:14 82
原创 单例
饿汉式public class Singleton {private static Singleton instance = new Singleton();private Singleton (){}public static Singleton getInstance() { return instance; }}双检锁public class Singleton ...
2020-04-14 20:05:51 79
原创 设计模式builder
```java在这里插入代码片package zuoye2;import java.awt.Graphics; abstract class PersonBuilder { protected Graphics g; public PersonBuilder(Graphics g){ this.g = g; } ...
2020-04-07 20:38:23 70
原创 设计模式---原型
在这里插入代码片package zuoye2;public class Resume implements Cloneable { private String name; private String sex; private String age; private String timearea; private String company; public ...
2020-04-07 20:36:51 69
原创 工厂
// 将工厂,又抽象了一层public interface OpreationFactory {Operation getOperation();}public class AddFactory implements OpreationFactory {@Overridepublic Operation getOperation() {return new Add();}}//...
2020-03-31 20:42:36 152
原创 工厂模式
package shejimoshizuooye;class interator{protected double ValueA;protected double ValueB;public void setA(double setvalue){ValueA = setvalue;}public void setB(double setvalue){ValueB = setv...
2020-03-31 20:38:12 71
原创 第二次作业设计模式
这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入欢迎使用M...
2020-03-10 19:48:29 548
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人