Minor updates to decorator pattern
This commit is contained in:
@@ -50,13 +50,13 @@ public class App {
|
||||
var troll = new SimpleTroll();
|
||||
troll.attack();
|
||||
troll.fleeBattle();
|
||||
LOGGER.info("Simple troll power {}.\n", troll.getAttackPower());
|
||||
LOGGER.info("Simple troll power: {}.\n", troll.getAttackPower());
|
||||
|
||||
// change the behavior of the simple troll by adding a decorator
|
||||
LOGGER.info("A troll with huge club surprises you.");
|
||||
var clubbedTroll = new ClubbedTroll(troll);
|
||||
clubbedTroll.attack();
|
||||
clubbedTroll.fleeBattle();
|
||||
LOGGER.info("Clubbed troll power {}.\n", clubbedTroll.getAttackPower());
|
||||
LOGGER.info("Clubbed troll power: {}.\n", clubbedTroll.getAttackPower());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user