forked from abishekaditya/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hammer.cs
36 lines (31 loc) · 781 Bytes
/
Hammer.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
using System;
namespace BridgePattern
{
public class Hammer:IWeapon
{
private readonly IEnchantment _enchantment;
public Hammer(IEnchantment enchantment)
{
_enchantment = enchantment;
}
public void Wield()
{
Console.WriteLine("The hammer is wielded.");
_enchantment.OnActivate();
}
public void Swing()
{
Console.WriteLine("The hammer is swinged.");
_enchantment.Apply();
}
public void Unwield()
{
Console.WriteLine("The hammer is unwielded.");
_enchantment.OnDeactivate();
}
public IEnchantment GetEnchantment()
{
return _enchantment;
}
}
}