Created
April 10, 2020 06:58
-
-
Save smkplus/a76f2475aa1fde6092de7e97c38674bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class Character | |
| { | |
| public int Armor { get; set; } | |
| public int Life { get; set; } | |
| public abstract void TakeDamage(int damage); | |
| } | |
| public class Warrior : Character | |
| { | |
| public override void TakeDamage(int damage) | |
| { | |
| Life -= Math.Max(0, damage - Armor); | |
| } | |
| } | |
| public class Mage : Character | |
| { | |
| public int MagicProtection { get; set; } | |
| public override void TakeDamage(int damage) | |
| { | |
| Life -= Math.Max(0, damage - Armor - MagicProtection); | |
| } | |
| } | |
| public class Rogue : Character | |
| { | |
| public int Furtivity { get; set; } | |
| public override void TakeDamage(int damage) | |
| { | |
| Life -= Math.Max(0, damage - Armor - Furtivity); | |
| } | |
| } | |
| public class DamageManager | |
| { | |
| public void CalculateDamage(Character character, int damage) | |
| { | |
| character?.TakeDamage(damage); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment