Merge remote-tracking branch 'origin/main'

This commit is contained in:
2026-10-09 15:34:46 +03:00
+29 -9
View File
@@ -5,10 +5,14 @@ public class two_ex
static void Main(string[] args)
{
Pokemon pikachu = new Pokemon(100, 5, "Пикачу");
Pokemon sqr = new Pokemon(90, 7, "Сквиртл");
pikachu.ShowInfo();
sqr.ShowInfo();
pikachu.HP = 100;
Console.WriteLine(pikachu.HP);
pikachu.TakeDamage(30);
Console.WriteLine(pikachu.HP);
pikachu.Heal();
Console.WriteLine(pikachu.HP);
Pokemon egg = new Pokemon();
Console.WriteLine(egg.HP+" "+egg.Level+" "+egg.Name);
}
}
@@ -55,17 +59,20 @@ class Pokemon
}
public void Heal()
{
hp = 100;
}
public Pokemon(int hp, int level, string name)
{
this.name = name;
this.level = level;
this.hp = hp;
}
public void ShowInfo()
{
Console.WriteLine($"HP: {this.HP}, Level: {this.Level}, Name: {this.Name}");
}
public int TakeDamage(int damage)
{
@@ -73,6 +80,19 @@ class Pokemon
if (hp <= 0) return 0;
return this.hp;
}
public Pokemon()
{
Name = "Яйцо";
Level = 1;
hp = 100;
}
}