From e464f7afd330585e5b44a366c6646aa6ecf3a47e Mon Sep 17 00:00:00 2001 From: Mamedka Date: Wed, 28 Oct 2026 00:14:59 +0300 Subject: [PATCH] Added lab 3 and lab 4 --- works/lab-03/lab3-1.cs | 30 ++++++++++++++++++++++ works/lab-03/lab3-2.cs | 24 +++++++++++++++++ works/lab-03/lab3-3.cs | 58 ++++++++++++++++++++++++++++++++++++++++++ works/lab-04/lab4-1.cs | 23 +++++++++++++++++ works/lab-04/lab4-2.cs | 21 +++++++++++++++ works/lab-04/lab4-3.cs | 29 +++++++++++++++++++++ 6 files changed, 185 insertions(+) create mode 100644 works/lab-03/lab3-1.cs create mode 100644 works/lab-03/lab3-2.cs create mode 100644 works/lab-03/lab3-3.cs create mode 100644 works/lab-04/lab4-1.cs create mode 100644 works/lab-04/lab4-2.cs create mode 100644 works/lab-04/lab4-3.cs diff --git a/works/lab-03/lab3-1.cs b/works/lab-03/lab3-1.cs new file mode 100644 index 0000000..74b0a12 --- /dev/null +++ b/works/lab-03/lab3-1.cs @@ -0,0 +1,30 @@ +using System; +namespace HelloWorldApplication +{ + class HelloWorld + { + static void Main(string[] args) + { + Console.WriteLine("Приготовьтесь!"); + + for (int i = 3; i >= 1; i--) + { + Console.WriteLine($"{i}..."); + } + + Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ==="); + + string pokemon1Name = "Пикачу"; + int pokemon1Hp = 50; + int pokemon1Attack = 12; + + string pokemon2Name = "Булбазавр"; + int pokemon2Hp = 55; + int pokemon2Attack = 10; + + int roundNumber = 1; + + Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})"); + } + } +} \ No newline at end of file diff --git a/works/lab-03/lab3-2.cs b/works/lab-03/lab3-2.cs new file mode 100644 index 0000000..5f764a4 --- /dev/null +++ b/works/lab-03/lab3-2.cs @@ -0,0 +1,24 @@ +using System; +namespace HelloWorldApplication +{ + class HelloWorld + { + 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("Вы отменили бой!"); + return; + } + } +} \ No newline at end of file diff --git a/works/lab-03/lab3-3.cs b/works/lab-03/lab3-3.cs new file mode 100644 index 0000000..89d8689 --- /dev/null +++ b/works/lab-03/lab3-3.cs @@ -0,0 +1,58 @@ +using System; +namespace HelloWorldApplication +{ + class HelloWorld + { + 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 -= pokemon1Attack; + if (pokemon2Hp <= 0) + { + pokemon2Hp = 0; + Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!"); + Console.WriteLine($"{pokemon2Name} потерял сознание!"); + break; + } + Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!"); + + pokemon1Hp -= pokemon2Attack; + if (pokemon1Hp <= 0) + { + pokemon1Hp = 0; + Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!"); + Console.WriteLine($"{pokemon1Name} потерял сознание!"); + break; + } + Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!"); + + Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}"); + Console.WriteLine(); + roundNumber++; +} + +Console.WriteLine(); +Console.WriteLine("=== БОЙ ОКОНЧЕН ==="); +if (pokemon1Hp > 0) +{ + Console.WriteLine($"Победитель: {pokemon1Name}!"); +} +else +{ + Console.WriteLine($"Победитель: {pokemon2Name}!"); +} + } + } +} \ No newline at end of file diff --git a/works/lab-04/lab4-1.cs b/works/lab-04/lab4-1.cs new file mode 100644 index 0000000..005cb37 --- /dev/null +++ b/works/lab-04/lab4-1.cs @@ -0,0 +1,23 @@ +using System; + +public class Test +{ + public static void Main() + { + string[] activeTeam = new string[3]; + +Console.WriteLine("=== РЕГИСТРАЦИЯ КОМАНДЫ ==="); +for (int i = 0; i < activeTeam.Length; i++) +{ + Console.Write($"Введите имя покемона №{i + 1}: "); + activeTeam[i] = Console.ReadLine(); +} + +Console.WriteLine(); +Console.WriteLine("--- Ваша команда на этот бой ---"); +Console.WriteLine($"1. {activeTeam[0]}"); +Console.WriteLine($"2. {activeTeam[1]}"); +Console.WriteLine($"3. {activeTeam[2]}"); +Console.WriteLine(); + } +} diff --git a/works/lab-04/lab4-2.cs b/works/lab-04/lab4-2.cs new file mode 100644 index 0000000..99831a6 --- /dev/null +++ b/works/lab-04/lab4-2.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +public class Test +{ + public static void Main() + { + List backpack = new List(); + +backpack.Add("Зелье HP"); +backpack.Add("Покебол"); +backpack.Add("Антидот"); + +Console.WriteLine("=== ИНВЕНТАРЬ ТРЕНЕРА ==="); +Console.WriteLine($"Вы положили вещи в сумку. Предметов в инвентаре: {backpack.Count}"); + +backpack.Remove("Покебол"); +Console.WriteLine("Вы использовали один Покебол для поимки дикого покемона!"); +Console.WriteLine($"Обновленный инвентарь. Осталось предметов: {backpack.Count}"); + } +} diff --git a/works/lab-04/lab4-3.cs b/works/lab-04/lab4-3.cs new file mode 100644 index 0000000..d325c0a --- /dev/null +++ b/works/lab-04/lab4-3.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; + +public class Test +{ + public static void Main() + { + List backpack = new List(); + +backpack.Add("Зелье HP"); +backpack.Add("Покебол"); +backpack.Add("Антидот"); + +Console.WriteLine("=== ИНВЕНТАРЬ ТРЕНЕРА ==="); +Console.WriteLine($"Вы положили вещи в сумку. Предметов в инвентаре: {backpack.Count}"); + +backpack.Remove("Покебол"); +Console.WriteLine("Вы использовали один Покебол для поимки дикого покемона!"); +Console.WriteLine($"Обновленный инвентарь. Осталось предметов: {backpack.Count}"); + +Console.WriteLine(); +Console.WriteLine("--- Содержимое вашей сумки ---"); +foreach (string item in backpack) +{ + Console.WriteLine($"[Предмет] -> {item}"); +} +Console.WriteLine("============================="); + } +}