diff --git a/works/csharp/Readme(lab 7).md b/works/csharp/Readme(lab 7).md new file mode 100644 index 0000000..e7d688b --- /dev/null +++ b/works/csharp/Readme(lab 7).md @@ -0,0 +1,96 @@ +using System.Net.Security; + +// task 1 +class Pokemon +{ + protected string name; + protected int level; + protected int hp; + + public Pokemon(string name, int level, int hp) + { + Name = name; + Level = level; + Hp = 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 virtual void Attack() + { + Console.WriteLine("Покемон атакует"); + } + + public void ShowInfo() + { + Console.Write($"{Name},(Ур. {Level}): "); + } +} +class Pikachu : Pokemon +{ + public Pikachu(int level, int hp) : base("Пикачу", level, hp) + { + } + public override void Attack() + { + Console.WriteLine("Пика-пика! Удар током!"); + } +} +class Squirtle : Pokemon +{ + public Squirtle(int level, int hp) : base("Сквиртл", level, hp) + { + } + public override void Attack() + { + Console.WriteLine("Сквирт-сквирт! Водяной пистолет!"); + } +} +class Charmander : Pokemon +{ + public Charmander(int level, int hp) : base("Чармандер", level, hp) + { + } + public override void Attack() + { + Console.WriteLine("Чар-чар! Огненный хвост!"); + } +} + +class Program +{ + static void Main(string[] args) + { + Pikachu pikachu = new Pikachu(5, 40); + Squirtle squirtle = new Squirtle(7, 44); + Charmander charmander = new Charmander(6, 39); + + Console.WriteLine("=== ПОКЕДЕКС: АТАКИ ==="); + + pikachu.ShowInfo(); + pikachu.Attack(); + + squirtle.ShowInfo(); + squirtle.Attack(); + + charmander.ShowInfo(); + charmander.Attack(); + + Console.ReadLine(); + } +} \ No newline at end of file