This commit is contained in:
Puzanova
2026-11-24 10:30:48 +03:00
parent 64f345b077
commit e2495c6bd4
+43 -23
View File
@@ -120,29 +120,49 @@ namespace task
pokedex["Charmander"] = 2; pokedex["Charmander"] = 2;
pokedex["Zubat"] = 3; pokedex["Zubat"] = 3;
// // Проверка наличия // Безопасное получение
// if (pokedex.ContainsKey("Pikachu")) if (pokedex.TryGetValue("Pikachu", out int num))
// { {
// Console.WriteLine(pokedex["Pikachu"]); // 25 Console.WriteLine(num);
// } }
// else
// // Безопасное получение {
// if (pokedex.TryGetValue("Missingno", out int num)) Console.WriteLine("Нет в покедексе");
// { }
// Console.WriteLine(num);
// } // Перебор
// else foreach (var pair in pokedex)
// { {
// Console.WriteLine("Нет в покедексе"); Console.WriteLine($"{pair.Key} -> {pair.Value}");
// } }
//
// // Перебор Console.WriteLine("задача 7");
// foreach (var pair in pokedex)
// { var attack1 = new Dictionary<string, int>();
// Console.WriteLine($"{pair.Key} -> {pair.Value}"); attack1["tackle"] = 20;
// } attack1["thunder"] = 40;
// attack1["quick"] = 10;
// int enemyHp = 75;
int turn = 0;
while (enemyHp > 0)
{
turn++;
switch (turn % 3)
{
case 0:
Console.WriteLine("tackle");
break;
case 1:
Console.WriteLine("thunder");
break;
default:
Console.WriteLine("quick");
break;
}
}