Skip to content

Commit

Permalink
Merge pull request iluwatar#800 from trumvekhuya/master
Browse files Browse the repository at this point in the history
Fix small points in Strategy and Decorator pattern.
  • Loading branch information
iluwatar authored Oct 21, 2018
2 parents db33cc5 + b3f0cc7 commit 3c6fb0c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions decorator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,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 = 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!
Troll clubbedTroll = new ClubbedTroll(troll);
clubbedTroll.attack(); // The troll tries to grab you! The troll swings at you with a club!
clubbedTroll.fleeBattle(); // The troll shrieks in horror and runs away!
```

## Applicability
Expand Down
8 changes: 4 additions & 4 deletions decorator/src/main/java/com/iluwatar/decorator/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public static void main(String[] args) {

// change the behavior of the simple troll by adding a decorator
LOGGER.info("A troll with huge club surprises you.");
troll = new ClubbedTroll(troll);
troll.attack();
troll.fleeBattle();
LOGGER.info("Clubbed troll power {}.\n", troll.getAttackPower());
Troll clubbedTroll = new ClubbedTroll(troll);
clubbedTroll.attack();
clubbedTroll.fleeBattle();
LOGGER.info("Clubbed troll power {}.\n", clubbedTroll.getAttackPower());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public class ClubbedTrollTest {

@Test
public void testClubbedTroll() throws Exception {
public void testClubbedTroll() {
// Create a normal troll first, but make sure we can spy on it later on.
final Troll simpleTroll = spy(new SimpleTroll());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void tearDown() {
}

@Test
public void testTrollActions() throws Exception {
public void testTrollActions() {
final SimpleTroll troll = new SimpleTroll();
assertEquals(10, troll.getAttackPower());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void testGoToBattle() {
* Verify if the dragon slayer uses the new strategy during battle after a change of strategy
*/
@Test
public void testChangeStrategy() throws Exception {
public void testChangeStrategy() {
final DragonSlayingStrategy initialStrategy = mock(DragonSlayingStrategy.class);
final DragonSlayer dragonSlayer = new DragonSlayer(initialStrategy);

Expand Down

0 comments on commit 3c6fb0c

Please sign in to comment.