Prototype.java
- public class Prototype implements Cloneable {
- private String name;
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- @Override
- protected Object clone() {
- // TODO Auto-generated method stub
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return null;
- }
- }
- }
Concreateprototype.java
- public class Concreateprototype extends Prototype{
- public Concreateprototype(String name) {
- // TODO Auto-generated constructor stub
- setName(name);
- }
- }