设计模式之原型模式 Prototype

设计模式之原型模式 Prototype

public class Sheep implements Cloneable,Serializable{
    
    private String sname;
    private Date birthday;
    
    @Override
    protected Object clone() throws CloneNotSupportedException {
        Object obj = super.clone();    
        return obj;
    }

    public Sheep(String sname, Date birthday) {
        super();
        this.sname = sname;
        this.birthday = birthday;
    }

    public String getSname() {
        return sname;
    }

    public void setSname(String sname) {
        this.sname = sname;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
    
}
sheep类

相关文章: