From 0055c543e921f0c1383e3dc0b29685233d20adbf Mon Sep 17 00:00:00 2001 From: Lenya228Cherevko Date: Thu, 1 Oct 2026 07:58:51 +0000 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?works/lab03=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- works/lab03/ex2.cs | 30 ++++++++++++++++++++++++++++ works/lab03/ex3.cs | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 works/lab03/ex2.cs create mode 100644 works/lab03/ex3.cs diff --git a/works/lab03/ex2.cs b/works/lab03/ex2.cs new file mode 100644 index 0000000..fdd0055 --- /dev/null +++ b/works/lab03/ex2.cs @@ -0,0 +1,30 @@ +namespace DefaultNamespace; + +public class ex2 +{ + static void Main(string[] args) + { + int choice; + do + { + Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): "); + choice = int.Parse(Console.ReadLine()); + + if (choice != 1 && choice != 0) + { + Console.WriteLine("Некорректная команда! Попробуйте снова."); + } + + } while (choice != 0 && choice != 1); + + if (choice == 0) + { + Console.WriteLine("Вы отменили бой!"); + } + + if (choice == 1) + { + Console.WriteLine("Вы начали бой!"); + } + } +} \ No newline at end of file diff --git a/works/lab03/ex3.cs b/works/lab03/ex3.cs new file mode 100644 index 0000000..9b2043a --- /dev/null +++ b/works/lab03/ex3.cs @@ -0,0 +1,50 @@ +namespace DefaultNamespace; + +public class ex3 +{ + static void Main(string[] args) + { + string pokemon1Name = "Пикачу"; + int pokemon1Hp = 50; + int pokemon1Attack = 12; + string pokemon2Name = "Булбазавар"; + int pokemon2Hp = 55; + int pokemon2Attack = 10; + int roundNumber = 1; + + while (pokemon1Hp > 0 && pokemon2Hp > 0) + { + Console.WriteLine($"--- Раунд {roundNumber} ---"); + pokemon2Hp = pokemon2Hp - pokemon1Attack; + if (pokemon2Hp <= 0) + { + Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} по {pokemon2Name}"); + Console.WriteLine($"{pokemon2Name} потерял сознание"); + pokemon2Hp = 0; + break; + } + pokemon1Hp = pokemon1Hp - pokemon2Attack; + if (pokemon1Hp <= 0) + { + Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} по {pokemon1Name}"); + Console.WriteLine($"{pokemon1Name} потерял сознание"); + pokemon1Hp = 0; + break; + } + Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}"); + roundNumber++; + + } + + Console.WriteLine(); + Console.WriteLine("=== Бой окончен ==="); + if (pokemon2Hp == 0) + { + Console.WriteLine($"Победитель: {pokemon1Name}"); + } + else + { + Console.WriteLine($"Победитель: {pokemon2Name}"); + } + } +} \ No newline at end of file