Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Composite
- {
- public class Character
- {
- public int Health { get; private set; }
- private readonly IDamageStrategy _damageStrategy;
- public Character(int health, IDamageStrategy damageStrategy)
- {
- Health = health;
- _damageStrategy = damageStrategy;
- }
- public void TakeDamage(int damage)
- {
- int finalDamage = _damageStrategy.CalculateFinalDamage(damage);
- Health -= finalDamage;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement