Обновить lab-5/lab_5.cs

This commit is contained in:
2026-09-30 10:59:55 +00:00
parent 243f6d96bf
commit f8ef2210d0
+70 -70
View File
@@ -1,70 +1,70 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace lab_5 namespace lab_5
{ {
internal class Program internal class Program
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
//z1 //z1
int pokemonHp = 20; int pokemonHp = 20;
Console.WriteLine("\n=== ПОКЕЦЕНТР: ЛЕЧЕНИЕ ==="); Console.WriteLine("\n=== ПОКЕЦЕНТР: ЛЕЧЕНИЕ ===");
Console.WriteLine("Текущее здоровье покемона: " + pokemonHp); Console.WriteLine("Текущее здоровье покемона: " + pokemonHp);
HealPokemon(ref pokemonHp); HealPokemon(ref pokemonHp);
Console.ReadKey(); Console.ReadKey();
//z2 //z2
Console.WriteLine("\n=== ИССЛЕДОВАНИЕ ЛОКАЦИИ ==="); Console.WriteLine("\n=== ИССЛЕДОВАНИЕ ЛОКАЦИИ ===");
Console.WriteLine("Вы зашли в траву............."); Console.WriteLine("Вы зашли в траву.............");
string pkmnName; string pkmnName;
int pkmnLevel; int pkmnLevel;
SearchBushes(out pkmnName, out pkmnLevel); SearchBushes(out pkmnName, out pkmnLevel);
Console.ReadKey(); Console.ReadKey();
//z3 //z3
Console.WriteLine("\n=== РЕГИСТРАЦИЯ НА ТУРНИР ==="); Console.WriteLine("\n=== РЕГИСТРАЦИЯ НА ТУРНИР ===");
string[] pokemons1 = { "Бульбазавр", "Чармандер" }; string[] pokemons1 = { "Бульбазавр", "Чармандер" };
string[] pokemons2 = { "Сквиртл", "Пикачу", "Псайдак", "Мяут" }; string[] pokemons2 = { "Сквиртл", "Пикачу", "Псайдак", "Мяут" };
double difficultyReg = 1.5; double difficultyReg = 1.5;
RegisterTournament(in difficultyReg, pokemons1); RegisterTournament(in difficultyReg, pokemons1);
Console.WriteLine("--------------------------------------"); Console.WriteLine("--------------------------------------");
RegisterTournament(in difficultyReg, pokemons2); RegisterTournament(in difficultyReg, pokemons2);
Console.ReadKey(); Console.ReadKey();
} }
static void HealPokemon(ref int pkmnHp) static void HealPokemon(ref int pkmnHp)
{ {
pkmnHp += 80; pkmnHp += 80;
if (pkmnHp > 100) if (pkmnHp > 100)
{ {
pkmnHp = 100; pkmnHp = 100;
Console.WriteLine($"[Покецентр] Покемон полностью здоров. Текущее хп: {pkmnHp}"); Console.WriteLine($"[Покецентр] Покемон полностью здоров. Текущее хп: {pkmnHp}");
} }
else else
{ {
Console.WriteLine("[Покецентр] Текущее хп после лечения " + pkmnHp); Console.WriteLine("[Покецентр] Текущее хп после лечения " + pkmnHp);
} }
} }
static void SearchBushes(out string foundPokemon, out int pokemonlevel) static void SearchBushes(out string foundPokemon, out int pokemonlevel)
{ {
Random randomnum = new Random(); Random randomnum = new Random();
pokemonlevel = randomnum.Next(1, 15); pokemonlevel = randomnum.Next(1, 15);
foundPokemon = "Пикачу"; foundPokemon = "Пикачу";
Console.WriteLine($"Шорох!! Из кустов появляется дикий {foundPokemon} (Уровень: {pokemonlevel})!"); Console.WriteLine($"Шорох!! Из кустов появляется дикий {foundPokemon} (Уровень: {pokemonlevel})!");
} }
static void RegisterTournament(in double difficulty, params string[] participants) static void RegisterTournament(in double difficulty, params string[] participants)
{ {
//difficulty = 1,3; //difficulty = 1,3;
Console.WriteLine("Коэффициент стадиона: " + difficulty); Console.WriteLine("Коэффициент стадиона: " + difficulty);
Console.WriteLine("Список участников: "); Console.WriteLine("Список участников: ");
foreach (string pokemon in participants) foreach (string pokemon in participants)
{ {
Console.WriteLine($"* {pokemon}"); Console.WriteLine($"* {pokemon}");
} }
} }
} }
} }