edit lab-03

This commit is contained in:
2026-09-21 10:11:57 +03:00
parent 22d3814139
commit 78a605a10c
5 changed files with 62 additions and 53 deletions
+19 -22
View File
@@ -8,7 +8,7 @@
## Ключевой код
```csharp
// Самая важная часть реализации (методы, структуры, логика)
internal class Program
internal class Program
{
static void Main(string[] args)
{
@@ -19,25 +19,23 @@
int pokemon2Hp = 55;
int pokemon2Attack = 10;
int roundNumber = 1;
int actionChoise;
//задание 2
do
{
Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): ");
int check = int.Parse(Console.ReadLine());
if (check == 0)
{
Console.WriteLine("\nВы отменили бой!");
break;
}
else if (check == 1)
{
Console.WriteLine("\nВы приняли бой!");
break;
}
else
Console.WriteLine("\nНекорректная команда! Попробуйте снова.");
}while (true);
actionChoise = int.Parse(Console.ReadLine());
if (actionChoise != 1 && actionChoise != 0)
Console.WriteLine("Некорректная команда! Попробуйте снова.");
}while (actionChoise != 1 && actionChoise != 0);
if (actionChoise == 0)
{
Console.WriteLine("\nВы отменили бой!");
}
else if (actionChoise == 1)
{
Console.WriteLine("\nВы приняли бой!");
}
//задание 1
Console.WriteLine("Приготовьтесь!");
for (int i = 3; i > 0; i--)
@@ -46,15 +44,15 @@
}
Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ===");
Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})");
//задание 3
while (pokemon1Hp > 0 && pokemon2Hp > 0)
{
Console.WriteLine($"--- Раунд {roundNumber} ---");
Console.WriteLine($"\n--- Раунд {roundNumber} ---");
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
pokemon2Hp -= pokemon1Attack;
if (pokemon2Hp <= 0)
@@ -76,10 +74,9 @@
break;
}
Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}");
Console.WriteLine();
roundNumber ++;
}
}
}