标签:变化 深克隆 cep 抽象 ati roman 开闭原则 对象 备忘录
class ConcretePrototype implements Prototype
{
private String attr; //成员属性
public void setAttr(String attr)
{
this.attr = attr;
}
public String getAttr()
{
return this.attr;
}
public Prototype clone() //克隆方法
{
Prototype prototype = new ConcretePrototype(); //创建新对象
prototype.setAttr(this.attr);
return prototype;
}
}
class ConcretePrototype implements Cloneable { …… public Prototype clone() { Object object = null; try { object = super.clone(); } catch (CloneNotSupportedException exception) { System.err.println("Not support cloneable"); } return (Prototype )object; } …… }
标签:变化 深克隆 cep 抽象 ati roman 开闭原则 对象 备忘录
原文地址:https://www.cnblogs.com/jiangtao1218/p/9451993.html