From 2ce8668e9a822aac9a5089742b44767ea994e69c Mon Sep 17 00:00:00 2001 From: ananesicim Date: Thu, 26 Nov 2026 17:47:23 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20works=20=D1=81#/lab=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- works с#/lab 3 | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 works с#/lab 3 diff --git a/works с#/lab 3 b/works с#/lab 3 new file mode 100644 index 0000000..45eb659 --- /dev/null +++ b/works с#/lab 3 @@ -0,0 +1,78 @@ +using System; + +class Program +{ + static void Main() + { + string pokemon1Name = "Пикачу"; + int pokemon1Hp = 50; + int pokemon1Attack = 12; + string pokemon2Name = "Булбазавр"; + int pokemon2Hp = 55; + int pokemon2Attack = 10; + int roundNumber = 1; + + Console.WriteLine("Приготовьтесь!"); + for (int i = 3; i >= 1; i--) + { + Console.WriteLine($"{i}..."); + } + Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ==="); + Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})"); + + int command; + do + { + Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): "); + command = int.Parse(Console.ReadLine()); + if (command != 1 && command != 0) + { + Console.WriteLine("Некорректная команда! Попробуйте снова."); + } + } while (command != 1 && command != 0); + + if (command == 0) + { + Console.WriteLine("Вы отменили бой!"); + return; + } + + while (pokemon1Hp > 0 && pokemon2Hp > 0) + { + Console.WriteLine(); + Console.WriteLine($"--- Раунд {roundNumber} ---"); + + pokemon2Hp -= pokemon1Attack; + Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!"); + if (pokemon2Hp <= 0) + { + pokemon2Hp = 0; + Console.WriteLine($"{pokemon2Name} потерял сознание!"); + break; + } + + pokemon1Hp -= pokemon2Attack; + Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!"); + if (pokemon1Hp <= 0) + { + pokemon1Hp = 0; + Console.WriteLine($"{pokemon1Name} потерял сознание!"); + break; + } + + Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}"); + roundNumber++; + } + + Console.WriteLine(); + Console.WriteLine("=== БОЙ ОКОНЧЕН ==="); + if (pokemon1Hp > 0) + { + Console.WriteLine($"Победитель: {pokemon1Name}!"); + } + else + { + Console.WriteLine($"Победитель: {pokemon2Name}!"); + } + } +}