-
Notifications
You must be signed in to change notification settings - Fork 617
/
Sword.cs
37 lines (31 loc) · 779 Bytes
/
Sword.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
namespace BridgePattern
{
public class Sword : IWeapon
{
private readonly IEnchantment _enchantment;
public Sword(IEnchantment enchantment)
{
_enchantment = enchantment;
}
public void Wield()
{
Console.WriteLine("The sword is wielded.");
_enchantment.OnActivate();
}
public void Swing()
{
Console.WriteLine("The sword is swinged.");
_enchantment.Apply();
}
public void Unwield()
{
Console.WriteLine("The sword is unwielded.");
_enchantment.OnDeactivate();
}
public IEnchantment GetEnchantment()
{
return _enchantment;
}
}
}