Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Полиморфизм_и__наследование_145
- {
- class Program
- {
- static void Main(string[] args)
- {
- Wombat w = new Wombat();
- w.Health = 100;
- w.TakeDamage(101);
- }
- }
- class Figthter
- {
- public int Health;
- public virtual void TakeDamage(int damage)
- {
- Health -= damage;
- Dead();
- }
- public void Dead()
- {
- if (Health <= 0)
- {
- Console.WriteLine("Я умер");
- }
- }
- }
- class Wombat : Figthter
- {
- public int Armor;
- public override void TakeDamage(int damage)
- {
- Health -= damage - Armor;
- Dead();
- }
- }
- class Human : Figthter
- {
- public int Agility;
- public override void TakeDamage(int damage)
- {
- Health -= damage / Agility;
- Dead();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement