ЛАбы
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", "{464362DE-7763-4A7F-899C-FFF1F309693C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{464362DE-7763-4A7F-899C-FFF1F309693C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{464362DE-7763-4A7F-899C-FFF1F309693C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{464362DE-7763-4A7F-899C-FFF1F309693C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{464362DE-7763-4A7F-899C-FFF1F309693C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,98 @@
|
||||
using System.Net.Security;
|
||||
// task 1
|
||||
class Pokemon
|
||||
{
|
||||
protected string name;
|
||||
protected int level;
|
||||
protected int hp;
|
||||
|
||||
public Pokemon(string name, int level, int hp)
|
||||
{
|
||||
Name = name;
|
||||
Level = level;
|
||||
Hp = hp;
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set { name = value; }
|
||||
}
|
||||
|
||||
public int Level
|
||||
{
|
||||
get { return level; }
|
||||
set { level = value; }
|
||||
}
|
||||
|
||||
public int Hp
|
||||
{
|
||||
get { return hp; }
|
||||
set { hp = value; }
|
||||
}
|
||||
|
||||
public virtual void Attack()
|
||||
{
|
||||
Console.WriteLine("Покемон атакует");
|
||||
}
|
||||
|
||||
public void ShowInfo()
|
||||
{
|
||||
Console.Write($"{Name},(Ур. {Level}): ");
|
||||
}
|
||||
}
|
||||
class Pikachu : Pokemon
|
||||
{
|
||||
public Pikachu(int level, int hp) : base("Пикачу", level, hp)
|
||||
{
|
||||
}
|
||||
public override void Attack()
|
||||
{
|
||||
Console.WriteLine("Пика-пика! Удар током!");
|
||||
}
|
||||
}
|
||||
class Squirtle : Pokemon
|
||||
{
|
||||
public Squirtle(int level, int hp) : base("Сквиртл", level, hp)
|
||||
{
|
||||
}
|
||||
public override void Attack()
|
||||
{
|
||||
Console.WriteLine("Сквирт-сквирт! Водяной пистолет!");
|
||||
}
|
||||
}
|
||||
class Charmander : Pokemon
|
||||
{
|
||||
public Charmander(int level, int hp) : base("Чармандер", level, hp)
|
||||
{
|
||||
}
|
||||
public override void Attack()
|
||||
{
|
||||
Console.WriteLine("Чар-чар! Огненный хвост!");
|
||||
}
|
||||
}
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Pikachu pikachu = new Pikachu(5, 40);
|
||||
Squirtle squirtle = new Squirtle(7, 44);
|
||||
Charmander charmander = new Charmander(6, 39);
|
||||
|
||||
Console.WriteLine("=== ПОКЕДЕКС: АТАКИ ===");
|
||||
|
||||
pikachu.ShowInfo();
|
||||
pikachu.Attack();
|
||||
|
||||
squirtle.ShowInfo();
|
||||
squirtle.Attack();
|
||||
|
||||
charmander.ShowInfo();
|
||||
charmander.Attack();
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
|
||||
// task 2
|
||||
|
||||
@@ -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