generated from admin/template
Merge branch 'main' of http://31.128.39.10:3000/polyphemus/prog-radzh #
Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch.
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
## input
|
||||
```csharp
|
||||
string pokemon1Name = "Пикачу";
|
||||
int pokemon1Hp = 50;
|
||||
int pokemon1Attack = 12;
|
||||
string pokemon2Name = "Булбазавр";
|
||||
int pokemon2Hp = 55;
|
||||
int pokemon2Attack = 10;
|
||||
int roundNumber = 1;
|
||||
```
|
||||
|
||||
## task 1
|
||||
```csharp
|
||||
Console.WriteLine("Приготовьтесь!");
|
||||
for (int i = 3 ; i >= roundNumber ; i--)
|
||||
{
|
||||
Console.WriteLine(i + "...");
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
Console.WriteLine("=== БОЙ НАЧИНАЕТСЯ ===");
|
||||
Console.WriteLine($"{pokemon1Name} (HP: {pokemon1Hp} | Атака: {pokemon1Attack}) VS {pokemon2Name} (HP: {pokemon2Hp} | Атака: {pokemon2Attack})");
|
||||
```
|
||||
|
||||
## task 2
|
||||
```csharp
|
||||
int choice;
|
||||
Console.Write("Готовы начать бой? (1 - Да, 0 - Нет): ");
|
||||
|
||||
do
|
||||
{
|
||||
choice = int.Parse(Console.ReadLine());
|
||||
if (choice == 1)
|
||||
{
|
||||
Console.WriteLine("Вы начали бой!");
|
||||
}
|
||||
|
||||
else if (choice == 0)
|
||||
{
|
||||
Console.WriteLine("Вы отменили бой!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Некорректная команда! Попробуйте снова.");
|
||||
}
|
||||
} while (choice != 1 && choice != 0);
|
||||
```
|
||||
|
||||
## task 3
|
||||
```csharp
|
||||
while (pokemon1Hp > 0 && pokemon2Hp > 0)
|
||||
{
|
||||
Console.WriteLine($"--- Раунд {roundNumber} ---");
|
||||
|
||||
pokemon2Hp -= pokemon1Attack;
|
||||
Console.WriteLine($"{pokemon1Name} наносит {pokemon1Attack} урона по {pokemon2Name}!");
|
||||
|
||||
if (pokemon2Hp <= 0)
|
||||
{
|
||||
pokemon2Hp = 0;
|
||||
Console.WriteLine($"{pokemon2Name} падает в нокаут!");
|
||||
break;
|
||||
}
|
||||
|
||||
pokemon1Hp -= pokemon2Attack;
|
||||
Console.WriteLine($"{pokemon2Name} наносит {pokemon2Attack} урона по {pokemon1Name}!");
|
||||
|
||||
if (pokemon1Hp <= 0)
|
||||
{
|
||||
pokemon1Hp = 0;
|
||||
Console.WriteLine($"{pokemon1Name} падает в нокаут!");
|
||||
break;
|
||||
}
|
||||
|
||||
Console.WriteLine($"Итог раунда: {pokemon1Name} HP: {pokemon1Hp} | {pokemon2Name} HP: {pokemon2Hp}\n");
|
||||
roundNumber++;
|
||||
}
|
||||
|
||||
Console.WriteLine("\n--- Конец боя ---");
|
||||
if (pokemon1Hp > 0 && pokemon2Hp <= 0)
|
||||
{
|
||||
Console.WriteLine($"Победитель: {pokemon1Name}!");
|
||||
}
|
||||
else if (pokemon2Hp > 0 && pokemon1Hp <= 0)
|
||||
{
|
||||
Console.WriteLine($"Победитель: {pokemon2Name}!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Ничья!");
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user