pandatoclone.java
来自「java与模式 一书的源码」· Java 代码 · 共 40 行
JAVA
40 行
package com.javapatterns.prototype.panda;
public class PandaToClone implements Cloneable
{
private int height, weight, age;
public PandaToClone (int height, int weight)
{
this.age = 0;
this.weight = weight;
this.height = height;
}
public void setAge(int age)
{
this.age = age;
}
public int getAge()
{
return age;
}
public int getHeight()
{
return height;
}
public int getWeight()
{
return weight;
}
public Object clone()
{
PandaToClone temp = new PandaToClone(height, weight);
temp.setAge(age);
return (Object) temp;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?