complete lab-05, start stage-05

This commit is contained in:
2026-09-24 10:13:12 +03:00
parent 78a605a10c
commit 9131c45fa6
11 changed files with 426 additions and 1 deletions
+56
View File
@@ -0,0 +1,56 @@
# Лабораторная работа №5
* **Студент:** Прибыткова Елизавета Дмитриевна
* **Тема:** [Функции и методы в C#. Возвращаемые значения и модификаторы параметров (ref, out, in, params)]
---
## Ключевой код
```csharp
int pokemonHP = 20;
Console.WriteLine("=== ПОКЕЦЕНТР: ЛЕЧЕНИЕ ===");
Console.WriteLine($"Здоровье до лечения: {pokemonHP} HP.");
HealPokemon(ref pokemonHP);
Console.WriteLine($"Здоровье после лечения: {pokemonHP} HP.");
Console.WriteLine("\n=== ИССЛЕДОВАНИЕ ЛОКАЦИИ ===");
Console.WriteLine("Вы зашли в высокую траву...");
SearchBushes(out string foundPokemon, out int pokemonLevel);
Console.WriteLine($"Шорох! Из кустов появляется дикий {foundPokemon} (Уровень: {pokemonLevel})!");
Console.WriteLine("\n=== РЕГИСТРАЦИЯ НА ТУРНИР ===");
double difficulty = 1.5;
RegisterTournament(difficulty, "Булбазавр", "Чармандер" );
Console.WriteLine("-----------------------------");
RegisterTournament(difficulty, "Сквиртл", "Пикачу", "Псайдак", "Мяут" );
Console.WriteLine("=============================");
void HealPokemon(ref int pokemonHP)
{
if (pokemonHP >= 100)
return;
pokemonHP += 80;
if (pokemonHP > 100)
pokemonHP = 100;
Console.WriteLine("[Покецентр] Покемон полностью здоров! Восстановлено 80 HP.");
}
void SearchBushes(out string foundPokemon, out int pokemonLevel)
{
foundPokemon = "Пикачу";
pokemonLevel = new Random().Next(1, 15);
}
void RegisterTournament(in double difficulty, params string[] participants)
{
//difficulty = 3;
Console.WriteLine($"Коэффициент стадиона: {difficulty}");
foreach (var pokemon in participants )
{
Console.WriteLine($"* {pokemon}");
}
}
```
---
![вывод.PNG](screenshots/%D0%B2%D1%8B%D0%B2%D0%BE%D0%B4.PNG)
Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

+44
View File
@@ -0,0 +1,44 @@
int pokemonHP = 20;
Console.WriteLine("=== ПОКЕЦЕНТР: ЛЕЧЕНИЕ ===");
Console.WriteLine($"Здоровье до лечения: {pokemonHP} HP.");
HealPokemon(ref pokemonHP);
Console.WriteLine($"Здоровье после лечения: {pokemonHP} HP.");
Console.WriteLine("\n=== ИССЛЕДОВАНИЕ ЛОКАЦИИ ===");
Console.WriteLine("Вы зашли в высокую траву...");
SearchBushes(out string foundPokemon, out int pokemonLevel);
Console.WriteLine($"Шорох! Из кустов появляется дикий {foundPokemon} (Уровень: {pokemonLevel})!");
Console.WriteLine("\n=== РЕГИСТРАЦИЯ НА ТУРНИР ===");
double difficulty = 1.5;
RegisterTournament(difficulty, "Булбазавр", "Чармандер" );
Console.WriteLine("-----------------------------");
RegisterTournament(difficulty, "Сквиртл", "Пикачу", "Псайдак", "Мяут" );
Console.WriteLine("=============================");
void HealPokemon(ref int pokemonHP)
{
if (pokemonHP >= 100)
return;
pokemonHP += 80;
if (pokemonHP > 100)
pokemonHP = 100;
Console.WriteLine("[Покецентр] Покемон полностью здоров! Восстановлено 80 HP.");
}
void SearchBushes(out string foundPokemon, out int pokemonLevel)
{
foundPokemon = "Пикачу";
pokemonLevel = new Random().Next(1, 15);
}
void RegisterTournament(in double difficulty, params string[] participants)
{
//difficulty = 3;
Console.WriteLine($"Коэффициент стадиона: {difficulty}");
foreach (var pokemon in participants )
{
Console.WriteLine($"* {pokemon}");
}
}
+11
View File
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>lab_05</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+16
View File
@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-05", "lab-05.csproj", "{D73CF250-78BC-4A3A-A9C4-679C3BBA1CC0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D73CF250-78BC-4A3A-A9C4-679C3BBA1CC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D73CF250-78BC-4A3A-A9C4-679C3BBA1CC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D73CF250-78BC-4A3A-A9C4-679C3BBA1CC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D73CF250-78BC-4A3A-A9C4-679C3BBA1CC0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal