From 393bb793da131a0c90b8d92da585e3bb8311193e Mon Sep 17 00:00:00 2001 From: Yroslav Date: Thu, 15 Oct 2026 06:45:27 +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/lesson-03=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- works/lesson-03/Readme.md | 15 ++++++ works/lesson-03/lesson-3.cs | 97 +++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 works/lesson-03/Readme.md create mode 100644 works/lesson-03/lesson-3.cs diff --git a/works/lesson-03/Readme.md b/works/lesson-03/Readme.md new file mode 100644 index 0000000..b228730 --- /dev/null +++ b/works/lesson-03/Readme.md @@ -0,0 +1,15 @@ +# Лабораторная работа №3 + +* **Студент:** Константинов Матвей Михайлович (gcn) +* **Вариант / Карточка:** [Например: #025 Pikachu] + +--- + +## Ключевой код +```csharp +// Самая важная часть реализации (методы, структуры, логика) +public class Card +{ + public string Name { get; set; } + public int Hp { get; set; } +} diff --git a/works/lesson-03/lesson-3.cs b/works/lesson-03/lesson-3.cs new file mode 100644 index 0000000..8128e6a --- /dev/null +++ b/works/lesson-03/lesson-3.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Program + { + public static void Main(string[] args) + { + string pokemon1Name = "Пикачу"; + int pokemon1Hp = 50; + int pokemon1Attack = 12; + string pokemon2Name = "Булбазавр"; + int pokemon2Hp = 55; + int pokemon2Attack = 10; + int roundNumber = 1; + int consFight; + + Console.WriteLine("Приготовьтесь!"); + for (int i = 1; i < 4; i++) + { + Console.WriteLine($"{i}..."); + } + + Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ==="); + Console.WriteLine( + $"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})"); + do + { + Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): "); + consFight = int.Parse(Console.ReadLine()); + if (consFight == 1) + { + break; + } + else if (consFight == 0) + { + break; + } + else + { + Console.WriteLine("Некорректная команда! Попробуйте снова."); + } + + } while (true); + + if (consFight == 1) + { + while (pokemon1Hp > 0 && pokemon2Hp > 0) + { + Console.WriteLine($"--- Раунд {roundNumber} ---"); + pokemon2Hp -= pokemon1Attack; + if (pokemon2Hp >= 0) + { + Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!"); + } + else + { + pokemon2Hp = 0; + Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!"); + Console.WriteLine($"{pokemon2Name} потерял сознание!"); + break; + } + + pokemon1Hp -= pokemon2Attack; + if (pokemon1Hp >= 0) + { + + Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!"); + } + else + { + pokemon1Hp = 0; + Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!"); + Console.WriteLine($"{pokemon1Name} потерял сознание!"); + break; + } + + Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp})"); + roundNumber += 1; + } + Console.WriteLine("=== БОЙ ОКОНЧЕН ==="); + if (pokemon1Hp <= 0) + { + Console.WriteLine($"Победитель: {pokemon2Name}!"); + } + else + { + Console.WriteLine($"Победитель: {pokemon1Name}!"); + } + } + } + } +} \ No newline at end of file