Skip to content

Commit e361223

Browse files
committed
Update bridge pattern readme
1 parent 7a46174 commit e361223

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

bridge/README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Decouple an abstraction from its implementation so that the two can vary indepen
1919

2020
## Explanation
2121

22-
Real world example
22+
Real-world example
2323

2424
> Consider you have a weapon with different enchantments, and you are supposed to allow mixing
2525
> different weapons with different enchantments. What would you do? Create multiple copies of each
@@ -161,27 +161,36 @@ public class SoulEatingEnchantment implements Enchantment {
161161
Here are both hierarchies in action:
162162

163163
```java
164+
LOGGER.info("The knight receives an enchanted sword.");
164165
var enchantedSword = new Sword(new SoulEatingEnchantment());
165166
enchantedSword.wield();
166167
enchantedSword.swing();
167168
enchantedSword.unwield();
168-
// The sword is wielded.
169-
// The item spreads bloodlust.
170-
// The sword is swinged.
171-
// The item eats the soul of enemies.
172-
// The sword is unwielded.
173-
// Bloodlust slowly disappears.
174169

170+
LOGGER.info("The valkyrie receives an enchanted hammer.");
175171
var hammer = new Hammer(new FlyingEnchantment());
176172
hammer.wield();
177173
hammer.swing();
178174
hammer.unwield();
179-
// The hammer is wielded.
180-
// The item begins to glow faintly.
181-
// The hammer is swinged.
182-
// The item flies and strikes the enemies finally returning to owner's hand.
183-
// The hammer is unwielded.
184-
// The item's glow fades.
175+
```
176+
177+
Here's the console output.
178+
179+
```
180+
The knight receives an enchanted sword.
181+
The sword is wielded.
182+
The item spreads bloodlust.
183+
The sword is swung.
184+
The item eats the soul of enemies.
185+
The sword is unwielded.
186+
Bloodlust slowly disappears.
187+
The valkyrie receives an enchanted hammer.
188+
The hammer is wielded.
189+
The item begins to glow faintly.
190+
The hammer is swung.
191+
The item flies and strikes the enemies finally returning to owner's hand.
192+
The hammer is unwielded.
193+
The item's glow fades.
185194
```
186195

187196
## Class diagram

0 commit comments

Comments
 (0)