generated from admin/template
new
This commit is contained in:
@@ -0,0 +1,196 @@
|
||||
# Задание: «Покецентр»
|
||||
|
||||
* **Студент:** [Пузанова Анна Андреевна]
|
||||
* **Задание: «Покецентр»** [
|
||||
---
|
||||
|
||||
## Ключевой код
|
||||
```csharp
|
||||
using System;
|
||||
namespace task
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("задача 1");
|
||||
string name = "Pikachu" ;
|
||||
string type = "electric";
|
||||
int level = 25;
|
||||
int hp = 120;
|
||||
double attack = 12.5 ;
|
||||
bool isShiny = false ;
|
||||
Console.WriteLine($"{name} ({type}), lvl {level}, HP {hp}, Atk {attack}, shiny: {isShiny}");
|
||||
hp += 30;
|
||||
level += 1;
|
||||
Console.WriteLine($"{name} ({type}), lvl {level}, HP {hp}, Atk {attack}, shiny: {isShiny}");
|
||||
|
||||
Console.WriteLine("задача 2");
|
||||
string attackerType = "fire";
|
||||
if (attackerType == "fire")
|
||||
{
|
||||
Console.WriteLine("Огонь силён против травы");
|
||||
}
|
||||
else if (attackerType == "water" )
|
||||
{
|
||||
Console.WriteLine("Вода сильна против огня");
|
||||
}
|
||||
else if (attackerType =="grass" )
|
||||
{
|
||||
Console.WriteLine("Трава сильна против воды");
|
||||
}
|
||||
else if (attackerType == "electric" )
|
||||
{
|
||||
Console.WriteLine("Электричество сильно против воды");
|
||||
}
|
||||
else Console.WriteLine("Тип не изучен");
|
||||
|
||||
Console.WriteLine("задача 3");
|
||||
string type1 = "water";
|
||||
Console.Write("Урон по water от grass: x");
|
||||
switch (type1)
|
||||
{
|
||||
case "grass":
|
||||
Console.WriteLine(2.0);
|
||||
break;
|
||||
case "electric":
|
||||
Console.WriteLine(0.5);
|
||||
break;
|
||||
case "fire":
|
||||
Console.WriteLine(0.5);
|
||||
break;
|
||||
case "water":
|
||||
Console.WriteLine(1.0);
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine(1.0);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// string type2 = number switch
|
||||
// {
|
||||
// "grass" => "2.0",
|
||||
// "electric" => "2.0",
|
||||
// "fire" => "0.5",
|
||||
// "water" => "0.5",
|
||||
// _ => "1.0"
|
||||
// };
|
||||
// Console.WriteLine($"Урон по water от grass: x{type1}");
|
||||
|
||||
|
||||
Console.WriteLine("задача 4");
|
||||
int hp1 = 100;
|
||||
int round = 0;
|
||||
|
||||
while (hp1 > 0)
|
||||
{
|
||||
round++;
|
||||
hp1 -= 17;
|
||||
Console.WriteLine($"Покемон продержался {round} раундов, HP = {hp1}");
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
Console.WriteLine(i);
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
if (i == 3) continue;
|
||||
if (i == 9) break;
|
||||
Console.WriteLine(i);
|
||||
}
|
||||
|
||||
|
||||
Console.WriteLine("задача 5");
|
||||
|
||||
List<string> team = new List<string>();
|
||||
team.Add("Pikachu");
|
||||
team.Add("Bulbasaur");
|
||||
team.Add("Charmander");
|
||||
team.Add("Zubat");
|
||||
|
||||
Console.WriteLine(team.Count);
|
||||
Console.WriteLine(team[1]);
|
||||
// foreach (string pokemon in team)
|
||||
// {
|
||||
// Console.WriteLine($"[Предмет] -> {item}");
|
||||
// }
|
||||
|
||||
|
||||
Console.WriteLine("задача 6");
|
||||
var pokedex = new Dictionary<string, int>();
|
||||
pokedex["Pikachu"] = 0;
|
||||
pokedex["Bulbasaur"] = 1;
|
||||
pokedex["Charmander"] = 2;
|
||||
pokedex["Zubat"] = 3;
|
||||
|
||||
// // Проверка наличия
|
||||
// if (pokedex.ContainsKey("Pikachu"))
|
||||
// {
|
||||
// Console.WriteLine(pokedex["Pikachu"]); // 25
|
||||
// }
|
||||
//
|
||||
// // Безопасное получение
|
||||
// if (pokedex.TryGetValue("Missingno", out int num))
|
||||
// {
|
||||
// Console.WriteLine(num);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.WriteLine("Нет в покедексе");
|
||||
// }
|
||||
//
|
||||
// // Перебор
|
||||
// foreach (var pair in pokedex)
|
||||
// {
|
||||
// Console.WriteLine($"{pair.Key} -> {pair.Value}");
|
||||
// }
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ВЫВОД:
|
||||
задача 1
|
||||
Pikachu (electric), lvl 25, HP 120, Atk 12,5, shiny: False
|
||||
Pikachu (electric), lvl 26, HP 150, Atk 12,5, shiny: False
|
||||
задача 2
|
||||
Огонь силён против травы
|
||||
задача 3
|
||||
Урон по water от grass: x1
|
||||
задача 4
|
||||
Покемон продержался 1 раундов, HP = 83
|
||||
Покемон продержался 2 раундов, HP = 66
|
||||
Покемон продержался 3 раундов, HP = 49
|
||||
Покемон продержался 4 раундов, HP = 32
|
||||
Покемон продержался 5 раундов, HP = 15
|
||||
Покемон продержался 6 раундов, HP = -2
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
1
|
||||
2
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
задача 5
|
||||
4
|
||||
Bulbasaur
|
||||
2
|
||||
Reference in New Issue
Block a user