Advertisement
Nemo048

Untitled

Jun 18th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _1451
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Wombat wombat = new Wombat()
  14.             {
  15.                 Health = 100,
  16.                 Armor = 10
  17.             };
  18.  
  19.             Human human = new Human()
  20.             {
  21.                 Health = 100,
  22.                 Agility = 5
  23.             };
  24.  
  25.             human.TakeDamage(110);
  26.             //wombat.TakeDamage(110);
  27.         }
  28.     }
  29.  
  30.     class Wombat : Entity
  31.     {
  32.         public int Armor;
  33.  
  34.         public new void TakeDamage(int damage)
  35.         {
  36.             base.TakeDamage(damage - Armor);
  37.         }
  38.     }
  39.  
  40.     class Human : Entity
  41.     {
  42.         public int Agility;
  43.  
  44.         public new void TakeDamage(int damage)
  45.         {
  46.             base.TakeDamage(damage / Agility);
  47.         }
  48.     }
  49.  
  50.     class Entity
  51.     {
  52.         public int Health;
  53.  
  54.         public void HealthTest()
  55.         {
  56.             if (Health <= 0)
  57.             {
  58.                 Console.WriteLine("Я умер");
  59.             }
  60.         }
  61.  
  62.         public virtual void TakeDamage(int damage)
  63.         {
  64.             Health -= damage;
  65.             HealthTest();
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement