This commit is contained in:
2026-10-06 15:54:52 +03:00
parent 03191a8a52
commit 26dca4f3e0
+52
View File
@@ -0,0 +1,52 @@
namespace DefaultNamespace;
public class ex1
{
static void Main(string[] args)
{
Pokemon pikachu = new Pokemon("Пикачу", 5, 100);
Pokemon sqr = new Pokemon("Сквиртл", 7, 90);
pikachu.ShowInfo();
sqr.ShowInfo();
}
}
class Pokemon
{
private string name;
private int level;
private int hp;
public string Name
{
get { return name; }
set { name = value; }
}
public int Level
{
get { return level; }
set { level = value; }
}
public int Hp
{
get { return hp; }
set { hp = value; }
}
public Pokemon(string name, int level, int hp)
{
this.name = name;
this.level = level;
this.hp = hp;
}
public void ShowInfo()
{
Console.WriteLine($"Имя: {this.Name}, Уровень: {this.Level}, HP: {this.Hp}");
}
}