private int height;
private int weight;
private Date birthDate;
private GoldRingdeStaff goldRingdeStaff;
public Mokey(){
birthDate= new Date();
}
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate){
this.birthDate =birthDate;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public Object clone(){
Mokey mokey=null;
try {
mokey=(Mokey)super.clone();
} catch(CloneNotSupportedException e) {
// TODO 自动生成catch 块
e.printStackTrace();
}
finally{
returnmokey;
}
}
public GoldRingdeStaff getGoldRingdeStaff(){
return goldRingdeStaff;
}
public void setGoldRingdeStaff(GoldRingdeStaffgoldRingdeStaff) {
this.goldRingdeStaff =goldRingdeStaff;
}
}
GoldRingdeStaff。JAVA
package desin.Prototype.lower;
public class GoldRingdeStaff {
private float height=100.0f;
private float weight=10.0f;
public float getHeight() {
return height;
}
public void setHeight(float height) {
this.height = height;
}
public float getWeight() {
return weight;
}
public void setWeight(float weight) {
this.weight = weight;
}
}
testClient.JAVA
package desin.Prototype.lower;
public class testClient {
private Mokey mokey= new Mokey();
public void change(){
Mokey copymokey2;
copymokey2=(Mokey)mokey.clone();
System.out.println("monkeybirth date :"+mokey.getBirthDate());
System.out.println("copymokey2birth date :"+copymokey2.getBirthDate());
System.out.println("copymokey2==monkey :"+(copymokey2==mokey));
System.out.println("copymokey2staff ==monkeystaff:"+(copymokey2.getGoldRingdeStaff()==mokey.getGoldRingdeStaff()));
}
public static void main(String[] args) {
// TODO 自动生成方法存根
testClient testClient= newtestClient();
testClient.change();
}
}