Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 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 num
  8. {
  9.     enum type { Archer = 0, Tank = 1, Thief = 2, Mage =3  }
  10.     enum name { Harold, Thor, Butch, Gerald}
  11.     class warrior
  12.     {
  13.         private name name;
  14.         private type type;
  15.         private int health;
  16.         private int damage;
  17.         private int armor;
  18.         private bool isAlive = true;
  19.         int battle_count;
  20.  
  21.         public warrior(name name, type type)
  22.         {
  23.             Random rnd = new Random();
  24.             this.name = name;
  25.             this.type = type;
  26.             health = 100;
  27.             armor = rnd.Next(10, 20);
  28.             damage = rnd.Next(10, 30);
  29.             battle_count = 20;
  30.         }
  31.        
  32.         public void takeDamage(int damage) {
  33.             HealthSystem(health - damage);
  34.         }
  35.         private void HealthSystem(int health)
  36.         {
  37.             if (health <= 0)
  38.                 isAlive = false;
  39.         }
  40.         public void print()
  41.         {
  42.             string life;
  43.             if (isAlive)
  44.                 life = "Живой";
  45.             else
  46.                 life = "Мертвый";
  47.             Console.WriteLine(name + " " + type + " " + health + " " + damage + " " + armor + " " + life);
  48.         }
  49.  
  50.     }
  51.  
  52.     class Program
  53.     {
  54.         static void Main(string[] args)
  55.         {
  56.             warrior Harold = new warrior(name.Harold, type.Tank);
  57.             Harold.takeDamage(30);
  58.             Harold.print();
  59.            
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement