generated from admin/template
Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -5,10 +5,14 @@ public class two_ex
|
|||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Pokemon pikachu = new Pokemon(100, 5, "Пикачу");
|
Pokemon pikachu = new Pokemon(100, 5, "Пикачу");
|
||||||
Pokemon sqr = new Pokemon(90, 7, "Сквиртл");
|
pikachu.HP = 100;
|
||||||
|
Console.WriteLine(pikachu.HP);
|
||||||
pikachu.ShowInfo();
|
pikachu.TakeDamage(30);
|
||||||
sqr.ShowInfo();
|
Console.WriteLine(pikachu.HP);
|
||||||
|
pikachu.Heal();
|
||||||
|
Console.WriteLine(pikachu.HP);
|
||||||
|
Pokemon egg = new Pokemon();
|
||||||
|
Console.WriteLine(egg.HP+" "+egg.Level+" "+egg.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +59,13 @@ class Pokemon
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Heal()
|
||||||
|
{
|
||||||
|
hp = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Pokemon(int hp, int level, string name)
|
public Pokemon(int hp, int level, string name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -62,10 +73,6 @@ class Pokemon
|
|||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowInfo()
|
|
||||||
{
|
|
||||||
Console.WriteLine($"HP: {this.HP}, Level: {this.Level}, Name: {this.Name}");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int TakeDamage(int damage)
|
public int TakeDamage(int damage)
|
||||||
{
|
{
|
||||||
@@ -73,6 +80,19 @@ class Pokemon
|
|||||||
if (hp <= 0) return 0;
|
if (hp <= 0) return 0;
|
||||||
return this.hp;
|
return this.hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Pokemon()
|
||||||
|
{
|
||||||
|
Name = "Яйцо";
|
||||||
|
Level = 1;
|
||||||
|
hp = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user