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 задача_3_var2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Human Jack = new Human(25, 5);
- Human Bobby = new Human(15, 3);
- Wombat Wombo = new Wombat(20, 15);
- Console.WriteLine("Битва началась.");
- Console.WriteLine("Вомбат нападает!");
- Bobby.TakeDamage(20);
- Console.WriteLine("Джек наносит удар вомбату");
- Wombo.TakeDamage(25);
- Console.WriteLine("Бобби наносит удар вомбату");
- Wombo.TakeDamage(10);
- Console.WriteLine("Вомбат нападает!");
- Jack.TakeDamage(45);
- Console.WriteLine("Вомбат нападает!");
- Jack.TakeDamage(100);
- Console.WriteLine("Бобби наносит удар вомбату");
- Wombo.TakeDamage(50);
- Console.ReadKey();
- }
- }
- class Mammals
- {
- public int Health;
- public Mammals(int health)
- {
- Health = health;
- }
- }
- interface IDamage
- {
- void TakeDamage(int damage);
- }
- class Wombat : Mammals, IDamage
- {
- public int Armor;
- public Wombat(int health, int armor):base(health)
- {
- Armor = armor;
- }
- public void TakeDamage(int damage)
- {
- Health -= damage - Armor;
- if (Health <= 0)
- {
- Console.WriteLine("Я умер");
- }
- }
- }
- class Human : Mammals, IDamage
- {
- public int Agility;
- public Human(int health, int agility):base(health)
- {
- Agility = agility;
- }
- public void TakeDamage(int damage)
- {
- Health -= damage / Agility;
- if (Health <= 0)
- {
- Console.WriteLine("Я умер");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment