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