Дополнил задание

This commit is contained in:
ArhaNge1
2026-10-16 15:58:17 +03:00
parent 6d0fa19b6f
commit e31b2cef51
27 changed files with 56 additions and 13 deletions
+64
View File
@@ -0,0 +1,64 @@
using System;
namespace ConsoleApp1
{
internal class Program
{
static void HealPokemon(ref int hp)
{
int healed = 100 - hp;
hp = 100;
Console.WriteLine($"[Покецентр] Покемон полностью здоров! Восстановлено {healed} HP.");
}
static void SearchBushes(out string foundPokemon, out int pokemonLevel)
{
Random rnd = new Random();
foundPokemon = "Пикачу";
pokemonLevel = rnd.Next(1, 16);
}
// Задание 3: in — только чтение, params — сколько угодно аргументов
static void RegisterTournament(in double difficulty, params string[] participants)
{
// difficulty = 2.0; // ошибка: in менять нельзя
Console.WriteLine($"Коэффициент стадиона: {difficulty}");
Console.WriteLine("Список участников:");
foreach (string p in participants)
{
Console.WriteLine($" * {p}");
}
Console.WriteLine("-----------------------------");
}
public static void Main(string[] args)
{
// Задание 1
Console.WriteLine("=== ПОКЕЦЕНТР: ЛЕЧЕНИЕ ===");
int pokemonHP = 20;
Console.WriteLine($"Здоровье до лечения: {pokemonHP} HP.");
HealPokemon(ref pokemonHP);
Console.WriteLine($"Здоровье после лечения: {pokemonHP} HP.");
// Задание 2
Console.WriteLine();
Console.WriteLine("=== ИССЛЕДОВАНИЕ ЛОКАЦИИ ===");
Console.WriteLine("Вы зашли в высокую траву...");
SearchBushes(out string wildName, out int wildLevel);
Console.WriteLine($"Шорох! Из кустов появляется дикий {wildName} (Уровень: {wildLevel})!");
// Задание 3
Console.WriteLine();
Console.WriteLine("=== РЕГИСТРАЦИЯ НА ТУРНИР ===");
double difficulty = 1.5;
RegisterTournament(in difficulty, "Булбазавр", "Чармандер");
RegisterTournament(in difficulty, "Сквиртл", "Пикачу", "Псайдак", "Мяут");
Console.WriteLine("=============================");
Console.ReadLine();
}
}
}