Advertisement
Nemo048

Untitled

Jun 18th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 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 _145
  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 void TakeDamage(int damage)
  35.         {
  36.             Health -= damage - Armor;
  37.             HealthTest();
  38.         }
  39.     }
  40.  
  41.     class Human : Entity
  42.     {
  43.         public int Agility;
  44.  
  45.         public void TakeDamage(int damage)
  46.         {
  47.             Health -= damage / Agility;
  48.             HealthTest();
  49.         }
  50.     }
  51.  
  52.     class Entity
  53.     {
  54.         public int Health;
  55.  
  56.         public void HealthTest()
  57.         {
  58.             if (Health <= 0)
  59.             {
  60.                 Console.WriteLine("Я умер");
  61.             }
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement