Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Enemy
- {
- protected int helth;
- public Enemy()
- {
- helth = 100;
- }
- public Enemy(int h)
- {
- helth = h;
- }
- public void move()
- {
- Console.WriteLine("Объект переместился на 1 шаг");
- }
- public override string ToString()
- {
- return "Enemy\n Helth: " + Convert.ToString(helth);
- }
- }
- class Human : Enemy
- {
- protected int damage;
- public Human() : base()
- {
- damage = 0;
- }
- public Human(int h, int d) : base(h)
- {
- damage = d;
- }
- public void attack()
- {
- Console.WriteLine("Произвден удар в {0} единиц", damage);
- }
- public override string ToString()
- {
- return "Human\n Helth: " + Convert.ToString(helth) +
- "\n Damage: " + Convert.ToString(damage);
- }
- }
- class MainClass
- {
- public static void Main(string[] args)
- {
- Enemy enm = new Enemy(150);
- Human hm = new Human(200, 50);
- Console.WriteLine(enm);
- enm.move();
- // enm.attack();
- Console.WriteLine(hm);
- hm.move();
- hm.attack();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement