mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-09-20 04:23:25 +00:00
Changes the description of the prototype pattern (#1102)
This commit is contained in:
1 parent
1fbe9bbac5
commit
a9c3df78ee
1 file changed
+6
-2
+6
-2
@@ -40,8 +40,12 @@ class Sheep implements Cloneable {
|
|||||||
public void setName(String name) { this.name = name; }
|
public void setName(String name) { this.name = name; }
|
||||||
public String getName() { return name; }
|
public String getName() { return name; }
|
||||||
@Override
|
@Override
|
||||||
public Sheep clone() throws CloneNotSupportedException {
|
public Sheep clone() {
|
||||||
return new Sheep(name);
|
try {
|
||||||
|
return (Sheep)super.clone();
|
||||||
|
} catch(CloneNotSuportedException) {
|
||||||
|
throw new InternalError();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in new issue
Block a user