Files
zxc-alexa/works/sharp/lab-05/Readme.md
T
zxc 908e7835c8 revert e7a1ff6588
revert demo
2026-10-09 10:21:00 +00:00

38 lines
1.3 KiB
Markdown

# Лабораторная работа №5
* **Студент:** [Саженина Александра]
* **Вариант / Карточка:** [Функции и методы в C#. Возвращаемые значения и модификаторы параметров (ref, out, in, params)]
---
## Ключевой код
```csharp
static void HealPokemon(ref int hp)
{
int healed = 100 - hp;
hp = 100;
Console.WriteLine($"[Покецентр] Покемон полностью здоров! Восстановлено {healed} HP.");
}
int pokemonHP = 20;
HealPokemon(ref pokemonHP);
static void SearchBushes(out string foundPokemon, out int pokemonLevel)
{
Random rnd = new Random();
foundPokemon = "Пикачу";
pokemonLevel = rnd.Next(1, 16);
}
SearchBushes(out string foundPokemon, out int pokemonLevel);
static void RegisterTournament(in double difficulty, params string[] participants)
{
Console.WriteLine($"Коэффициент стадиона: {difficulty}");
Console.WriteLine("Список участников:");
foreach (string p in participants)
Console.WriteLine($" * {p}");
}
double difficulty = 1.5;
RegisterTournament(in difficulty, "Булбазавр", "Чармандер");
RegisterTournament(in difficulty, "Сквиртл", "Пикачу", "Псайдак", "Мяут");