大话设计模式--简历复印--原型模式
//简历
class Resume implements ICloneable{
private String name;
private String sex;
private String age;
private String timeArea;
prviate String company;
public Resume(String name){
this.name = name;}
public void SetPersonalInfo(String sex,String age){
this.sex = sex;
this.age = age;
}
//设置工作经历
public void setWorkExceprice(String timeArea,String company){
this.timeArea = timeArea;
this.company = company;
}
public void DisPlay(){
System.out.println("anme,sex,age:"+name+sex+age);
System.out.println("工作经历:"+timeArea+company);
}
public Object Clone(){
return (Object) this.MemberWiseClone();
}
}
MainTest里
Resume a = new Resume("大鸟");
a.SetPersonalInfo("男","29");
a.setWorkExperience("1998-2000","xx公司");
Resume b = (Resume)a.clone();
b.setWorkExceperice("1998-2006","yy企业");
Resume c = (Resume)a.clone();
c.setPersonInfo("男","24");
a.display();
b.display();
c.display();