Delete duplicate declared objects:ClubbedTroll

Trolls should not be re-declared: if I had a troll called Zac, one day I
gave him a weapon.I can not because he now has a weapon called him
Trundle. He is still Zac.
This commit is contained in:
OCN.Yang 2017-09-14 10:20:20 +08:00
parent 2e90f82cab
commit 6a560f7d15
2 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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());
}
}