Skip to content

Commit

Permalink
updates to prototype pattern example
Browse files Browse the repository at this point in the history
  • Loading branch information
bethrobson committed Jan 8, 2020
1 parent b7c3505 commit 98d4286
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/headfirst/designpatterns/prototype/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public static void main(String[] args) {
Monster dragon = new Dragon("Dragon", false); // prototype for all Dragons
Monster drakon = new Drakon("Drakon", 2, true); // prototype for all Drakons

Monster laconian = makeMonster(drakon, "Laconian");
Monster ladon = makeMonster(dragon, "Ladon");
Monster ladon = makeMonsterOperation(dragon, "Ladon");
Monster laconian = makeMonsterOperation(drakon, "Laconian");

System.out.println(ladon);
ladon.spitPoison();
Expand All @@ -15,7 +15,7 @@ public static void main(String[] args) {
laconian.spitPoison();
}

public static Monster makeMonster(Monster monsterToCopy, String name) {
public static Monster makeMonsterOperation(Monster monsterToCopy, String name) {
Monster newMonster = null;
try {
newMonster = monsterToCopy.copy();
Expand Down
1 change: 1 addition & 0 deletions src/headfirst/designpatterns/prototype/Dragon.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class Dragon extends Monster {
public Dragon(String name, boolean hasWings) {
super(name);
this.hasWings = hasWings;
this.canBreatheFire = true;
}
// Each concrete monster could determine how best to clone itself
public Monster copy() throws CloneNotSupportedException {
Expand Down

0 comments on commit 98d4286

Please sign in to comment.