/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/csharp/csharp-505-25-007/main.cs
42 строки
1 KB
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
using System; public class Unit { public string Name = "Имя"; public int Intel = 10; public int Agility = 10; public int Strength = 10; public int Health = 100; public int Mana = 50; public int Level = 1; public int Damage { get { return (Intel + Agility + Strength) + (Level * 2); } } public void Attack(Unit target) { Console.WriteLine($"{Name} атакует {target.Name} и наносит {Damage} единиц урона."); target.Health -= Damage; Console.WriteLine($"{target.Name} теперь имеет {target.Health} здоровья."); } public static void Main(string[] args) { Unit warrior = new Unit(); warrior.Name = "Воин"; warrior.Intel = 5; warrior.Agility = 15; warrior.Strength = 30; Unit mage = new Unit(); mage.Name = "Маг"; mage.Intel = 35; mage.Agility = 10; mage.Strength = 5; warrior.Attack(mage); mage.Attack(warrior); } }