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:
parent
2e90f82cab
commit
6a560f7d15
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user