сделаны лаба 3,лаба 4 и стейджи 2,3

This commit is contained in:
Anna
2026-09-30 19:18:24 +03:00
parent cccf2c598d
commit 9e379bdc48
6 changed files with 515 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
# Лабораторная работа №2
* **Студент:** Хорошилкина Анна Дмитриевна
* **Вариант / Карточка:** [Например: #025 Pikachu]
---
## Ключевой код
```csharp
// Самая важная часть реализации (методы, структуры, логика)
public class Card
{
public string Name { get; set; }
public int Hp { get; set; }
}
+91
View File
@@ -0,0 +1,91 @@
using System;
using System.Text;
class Program
{
static void Main(string[] args)
{
Console.OutputEncoding = Encoding.UTF8;
//задание 1
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})");
Console.WriteLine();
//задание 2
int userChoice = 1;
if (userChoice == 0)
{
Console.WriteLine("Вы отменили бой!");
return;
}
Console.WriteLine();
//задание 3
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}");
Console.WriteLine();
roundNumber++;
}
Console.WriteLine();
Console.WriteLine("=== БОЙ ОКОНЧЕН ===");
if (pokemon1Hp > 0)
{
Console.WriteLine($"Победитель: {pokemon1Name}!");
}
else if (pokemon2Hp > 0)
{
Console.WriteLine($"Победитель: {pokemon2Name}!");
}
else
{
Console.WriteLine("Ничья!");
}
}
}