diff --git a/works/lab 6/src/two ex.cs b/works/lab 6/src/two ex.cs index 75060fc..7219b26 100644 --- a/works/lab 6/src/two ex.cs +++ b/works/lab 6/src/two ex.cs @@ -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; + } + + + + + + }