generated from admin/template
Backup
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-07", "lab-07\lab-07.csproj", "{F608480B-8D2E-4069-A2AB-5420A1102070}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F608480B-8D2E-4069-A2AB-5420A1102070}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F608480B-8D2E-4069-A2AB-5420A1102070}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F608480B-8D2E-4069-A2AB-5420A1102070}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F608480B-8D2E-4069-A2AB-5420A1102070}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,166 @@
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// Pokemon pika = new Pikachu("Пикачу", 5, 100);
|
||||
// Pokemon squirtle = new Squirtle("Сквиртл", 7, 90);
|
||||
// Pokemon charmander = new Charmander("Charmander", 9, 80);
|
||||
Console.WriteLine("=== ЗАДАНИЕ 1 ===");
|
||||
Console.WriteLine("=== ПОКЕДЕКС: АТАКИ ===\n");
|
||||
List<Pokemon> pokemons = new List<Pokemon>(4)
|
||||
{
|
||||
new Pikachu("Пикачу", 5, 100),
|
||||
new Squirtle("Сквиртл", 7, 90),
|
||||
new Charmander("Чармандер", 9, 80),
|
||||
new Bulbasaur("Бульбазавр", 6, 95)
|
||||
};
|
||||
foreach (Pokemon pokemon in pokemons)
|
||||
{
|
||||
pokemon.ShowInfo();
|
||||
pokemon.Attack();
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
// class Pokemon
|
||||
// {
|
||||
// protected string name;
|
||||
//
|
||||
// protected int hp;
|
||||
//
|
||||
// protected int level;
|
||||
//
|
||||
// public int HP
|
||||
// {
|
||||
// get { return hp; }
|
||||
// set
|
||||
// {
|
||||
// if (value < 0) hp = 0;
|
||||
// else if (value > 100) hp = 100;
|
||||
// else hp = value;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public int Level
|
||||
// {
|
||||
// get { return level; }
|
||||
// set
|
||||
// {
|
||||
// if (value < 1) level = 1;
|
||||
// else if (value > 100) level = 100;
|
||||
// else level = value;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public string Name;
|
||||
//
|
||||
// public Pokemon(string name, int level, int hp)
|
||||
// {
|
||||
// this.Name = name == "" ? "Безымянный" : name;
|
||||
// this.Level = level;
|
||||
// this.HP = hp;
|
||||
// }
|
||||
//
|
||||
// public abstract void Attack()
|
||||
// {
|
||||
// Console.WriteLine("Покемон аттакует");
|
||||
// }
|
||||
//
|
||||
// public void ShowInfo()
|
||||
// {
|
||||
// Console.WriteLine($"Name: {Name}, Уровень: {Level}, HP: {HP}");
|
||||
// }
|
||||
// }
|
||||
abstract class Pokemon
|
||||
{
|
||||
protected string name;
|
||||
|
||||
protected int hp;
|
||||
|
||||
protected int level;
|
||||
|
||||
public int HP
|
||||
{
|
||||
get { return hp; }
|
||||
set
|
||||
{
|
||||
if (value < 0) hp = 0;
|
||||
else if (value > 100) hp = 100;
|
||||
else hp = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Level
|
||||
{
|
||||
get { return level; }
|
||||
set
|
||||
{
|
||||
if (value < 1) level = 1;
|
||||
else if (value > 100) level = 100;
|
||||
else level = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name;
|
||||
|
||||
public Pokemon(string name, int level, int hp)
|
||||
{
|
||||
this.Name = name == "" ? "Безымянный" : name;
|
||||
this.Level = level;
|
||||
this.HP = hp;
|
||||
}
|
||||
|
||||
virtual public void Attack()
|
||||
{
|
||||
Console.WriteLine("Покемон аттакует");
|
||||
}
|
||||
|
||||
public void ShowInfo()
|
||||
{
|
||||
Console.WriteLine($"Name: {Name}, Уровень: {Level}, HP: {HP}");
|
||||
}
|
||||
}
|
||||
class Pikachu : Pokemon
|
||||
{
|
||||
public Pikachu(string name, int level, int hp) : base(name, level, hp)
|
||||
{
|
||||
|
||||
}
|
||||
public override void Attack()
|
||||
{
|
||||
Console.WriteLine($"{Name} бьёт током! Пика-пика!");
|
||||
}
|
||||
}
|
||||
class Charmander : Pokemon
|
||||
{
|
||||
public Charmander(string name, int level, int hp) : base(name, level, hp)
|
||||
{
|
||||
|
||||
}
|
||||
public override void Attack()
|
||||
{
|
||||
Console.WriteLine($"{Name} Чар-чар! Огненный хвост!");
|
||||
}
|
||||
}
|
||||
class Squirtle : Pokemon
|
||||
{
|
||||
public Squirtle(string name, int level, int hp) : base(name, level, hp)
|
||||
{
|
||||
|
||||
}
|
||||
public override void Attack()
|
||||
{
|
||||
Console.WriteLine($"{Name} Сквирт-сквирт! Водяной пистолет!");
|
||||
}
|
||||
}
|
||||
class Bulbasaur : Pokemon
|
||||
{
|
||||
public Bulbasaur(string name, int level, int hp) : base(name, level, hp)
|
||||
{
|
||||
|
||||
}
|
||||
public override void Attack()
|
||||
{
|
||||
Console.WriteLine($"{Name} Бульба! Листовой удар!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace>lab_07</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user