generated from admin/template
new
This commit is contained in:
@@ -27,7 +27,6 @@ namespace lab5
|
||||
|
||||
static void SearchBushes(out string foundPokemon, out int pokemonLevel)
|
||||
{
|
||||
|
||||
foundPokemon = "Пикачу";
|
||||
Random rnd = new Random();
|
||||
pokemonLevel = rnd.Next(1, 15);
|
||||
@@ -47,8 +46,6 @@ namespace lab5
|
||||
{
|
||||
Console.WriteLine($"Коэффициент стадиона: {difficulty}");
|
||||
Console.WriteLine($"Список участников:");
|
||||
|
||||
|
||||
foreach (string pokemon in participants)
|
||||
{
|
||||
Console.WriteLine($"* {pokemon}");
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
private string name;
|
||||
private int level;
|
||||
private int hp;
|
||||
|
||||
|
||||
|
||||
|
||||
public string Name
|
||||
@@ -101,7 +103,7 @@
|
||||
public static int Count { get; private set; } = 0;
|
||||
Pokemon winner;
|
||||
Pokemon loser;
|
||||
|
||||
|
||||
public void Battle(Pokemon enemy)
|
||||
{
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class Pikachu : Pokemon
|
||||
// тут можно добавить что-то своё
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Console.WriteLine("=== ТУРНИР: ВСЕ ПРОТИВ ВСЕХ ===");
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
# Лабораторная работа №7
|
||||
|
||||
* **Студент:** [Пузанова Анна Андреевна]
|
||||
* **Лабораторная работа №7:** [Тема: Тема: Наследование и полиморфизм в C#. Абстрактные классы, виртуальные методы и интерфейсы]
|
||||
|
||||
---
|
||||
|
||||
## Ключевой код
|
||||
```csharp
|
||||
class Pokemon
|
||||
{
|
||||
public string Name;
|
||||
public int Level;
|
||||
public int HP;
|
||||
|
||||
|
||||
public int HP
|
||||
{
|
||||
get { return hp; }
|
||||
set
|
||||
{
|
||||
if (value < 0) hp = 0;
|
||||
else if (value > 100) hp = 100;
|
||||
else hp = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Pikachu : Pokemon
|
||||
{
|
||||
public Pikachu(string name, int level) : base(name, level)
|
||||
{
|
||||
// тут можно добавить что-то своё
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Console.WriteLine("=== ТУРНИР: ВСЕ ПРОТИВ ВСЕХ ===");
|
||||
|
||||
abstract class Pokemon
|
||||
{
|
||||
public abstract void Attack();
|
||||
}
|
||||
|
||||
|
||||
ВЫВОД:
|
||||
=== ЗАДАНИЕ 1 ===
|
||||
=== ПОКЕДЕКС ===
|
||||
Имя: Пикачу, Уровень: 5, HP: 100
|
||||
Имя: Сквиртл, Уровень: 5, HP: 90
|
||||
=== ЗАДАНИЕ 2 ===
|
||||
=== ПРОВЕРКА ИНКАПСУЛЯЦИИ ===
|
||||
Попытка установить HP = -50...
|
||||
Текущее HP: 0 (защита сработала)
|
||||
Покемон получил 30 урона. HP: 70
|
||||
Покемон вылечился. HP: 100
|
||||
=== ЗАДАНИЕ 3 ===
|
||||
=== ПОКЕДЕКС: СТАТИСТИКА ===
|
||||
Создано покемонов: 3
|
||||
=== БИТВА ===
|
||||
Пикачу (Ур. 5), HP 100 против Сквиртл (Ур. 5), HP 90
|
||||
Силы равны! Ничья.
|
||||
|
||||
Reference in New Issue
Block a user