diff --git a/decorator/README.md b/decorator/README.md index 5f86166fe..37cfd88df 100644 --- a/decorator/README.md +++ b/decorator/README.md @@ -105,9 +105,9 @@ troll.attack(); // The troll tries to grab you! troll.fleeBattle(); // The troll shrieks in horror and runs away! // change the behavior of the simple troll by adding a decorator -Troll clubbed = new ClubbedTroll(troll); -clubbed.attack(); // The troll tries to grab you! The troll swings at you with a club! -clubbed.fleeBattle(); // The troll shrieks in horror and runs away! +troll = new ClubbedTroll(troll); +troll.attack(); // The troll tries to grab you! The troll swings at you with a club! +troll.fleeBattle(); // The troll shrieks in horror and runs away! ``` ## Applicability diff --git a/decorator/src/main/java/com/iluwatar/decorator/App.java b/decorator/src/main/java/com/iluwatar/decorator/App.java index 14cb8aa89..5b072b9c2 100644 --- a/decorator/src/main/java/com/iluwatar/decorator/App.java +++ b/decorator/src/main/java/com/iluwatar/decorator/App.java @@ -57,9 +57,9 @@ public class App { // change the behavior of the simple troll by adding a decorator LOGGER.info("A troll with huge club surprises you."); - Troll clubbed = new ClubbedTroll(troll); - clubbed.attack(); - clubbed.fleeBattle(); - LOGGER.info("Clubbed troll power {}.\n", clubbed.getAttackPower()); + troll = new ClubbedTroll(troll); + troll.attack(); + troll.fleeBattle(); + LOGGER.info("Clubbed troll power {}.\n", troll.getAttackPower()); } }