From addd8aab57710c7696ea5265dedc413a65293b1a Mon Sep 17 00:00:00 2001 From: solomov_b <62+solomov_b@noreply.localhost> Date: Tue, 24 Nov 2026 07:14:03 +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/charp/lab-03/lab03/Program.cs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- works/charp/lab-03/lab03/Program.cs | 83 +++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 works/charp/lab-03/lab03/Program.cs diff --git a/works/charp/lab-03/lab03/Program.cs b/works/charp/lab-03/lab03/Program.cs new file mode 100644 index 0000000..5128e99 --- /dev/null +++ b/works/charp/lab-03/lab03/Program.cs @@ -0,0 +1,83 @@ +namespace lab03 +{ + class Lab03Tasks + { + static void Main(string[] args) + { + /*Console.WriteLine("1 ЗАДАНИЕ"); + string pokemon1Name = "Пикачу"; + int pokemon1Hp = 50; + int pokemon1Attack = 12; + string pokemon2Name = "Булбазавр"; + int pokemon2Hp = 55; + int pokemon2Attack = 10; + int roundNumber = 1; + for (int i = 3; i > 0 ; i--) + { + Console.WriteLine($"{i}.."); + } + + Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ==="); + Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})"); */ + + + + Console.WriteLine("2 ЗАДАНИЕ"); + int choice; + + do + { + Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): "); + choice = int.Parse(Console.ReadLine()); + + if (choice != 1 && choice != 0) + { + Console.WriteLine("Некорректная команда! Попробуйте снова."); + } + } while (choice != 1 && choice != 0); + + if (choice == 0) + { + Console.WriteLine("Вы отменили бой!"); + } + + + + Console.WriteLine("3 ЗАДАНИЕ"); + string pokemon1Name = "Пикачу"; + string pokemon2Name = "Булбазавр"; + int pokemon1Attack = 12; + int pokemon2Attack = 10; + int pokemon1Hp = 50; + int pokemon2Hp = 55; + int roundNumber = 1; + + while (pokemon1Hp > 0 && pokemon2Hp > 0) + { + Console.WriteLine($"--- Раунд {roundNumber} ---"); + Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!"); + pokemon2Hp -= pokemon1Attack; + if (pokemon2Hp <= 0) + { + pokemon2Hp = 0; + Console.WriteLine($"{pokemon2Name} потерял сознание!"); + Console.WriteLine("=== БОЙ ОКОНЧЕН ==="); + Console.WriteLine($"Победитель: {pokemon1Name}"); + break; + } + Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!"); + pokemon1Hp -= pokemon2Attack; + if (pokemon1Hp <= 0 ) + { + pokemon1Hp = 0; + Console.WriteLine($"{pokemon1Name} потерял сознание!"); + Console.WriteLine("=== БОЙ ОКОНЧЕН ==="); + Console.WriteLine($"Победитель: {pokemon2Name}"); + break; + } + roundNumber++; + Console.WriteLine($"Итог раунда: Пикачу HP: {pokemon1Hp} | Булбазавр HP: {pokemon2Hp}"); + } + } + } +} \ No newline at end of file