diff --git a/works/C#/lab-06/lesson6/lesson6.sln b/works/C#/lab-06/lesson6/lesson6.sln new file mode 100644 index 0000000..10634e9 --- /dev/null +++ b/works/C#/lab-06/lesson6/lesson6.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lesson6", "lesson6\lesson6.csproj", "{A31EA002-0F0C-4893-81F6-C620F32573DB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A31EA002-0F0C-4893-81F6-C620F32573DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A31EA002-0F0C-4893-81F6-C620F32573DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A31EA002-0F0C-4893-81F6-C620F32573DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A31EA002-0F0C-4893-81F6-C620F32573DB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/works/C#/lab-06/lesson6/lesson6/Program.cs b/works/C#/lab-06/lesson6/lesson6/Program.cs new file mode 100644 index 0000000..30a93f0 --- /dev/null +++ b/works/C#/lab-06/lesson6/lesson6/Program.cs @@ -0,0 +1,78 @@ +class Pokemon +{ + private string name; + private int level; + private int hp; + + public string Name + { + get { return name; } + set + { + name = string.IsNullOrWhiteSpace(value) ? "Безымянный" : value; + } + } + + public int Level + { + get { return level; } + set + { + if (value < 1) level = 1; + else if (value > 100) level = 100; + else level = value; + } + } + + public int Hp + { + get { return hp; } + set + { + if (value <0) hp = 0; + else if (value > 100) hp = 100; + else hp = value; + } + } + public Pokemon() + { + Name = ""; + Level = 1; + Hp = 100; + } + public Pokemon(string name, int level, int hp) + { + Name = name; + Level = level; + Hp = hp; + } + + public void takeDamage(int damage) + { + Hp -= damage; + } + + public void Heal() + { + Hp = 100; + } +} + +class Program +{ + static void Main(string[] args) + { + Console.WriteLine("=== ПРОВЕРКА ИНКАПСУЛЯЦИИ ==="); + Pokemon pokemon = new Pokemon("Пикачу", 5, 100); + Console.WriteLine("Попытка установить HP = -50..."); + pokemon.Hp = -50; + Console.WriteLine($"Текущее HP: {pokemon.Hp} (защита сработала)"); + pokemon.Hp = 100; + pokemon.takeDamage(30); + Console.WriteLine($"Покемон получил 30 урона. HP: {pokemon.Hp}"); + pokemon.Heal(); + Console.WriteLine($"Покемон вылечился. HP: {pokemon.Hp}"); + } +} + + diff --git a/works/C#/lab-06/lesson6/lesson6/lesson6.csproj b/works/C#/lab-06/lesson6/lesson6/lesson6.csproj new file mode 100644 index 0000000..6c1dc92 --- /dev/null +++ b/works/C#/lab-06/lesson6/lesson6/lesson6.csproj @@ -0,0 +1,10 @@ + + + + Exe + net10.0 + enable + enable + + + diff --git a/works/C#/Срез/ConsoleApp1/ConsoleApp1.sln b/works/C#/Срез/ConsoleApp1/ConsoleApp1.sln new file mode 100644 index 0000000..41d6762 --- /dev/null +++ b/works/C#/Срез/ConsoleApp1/ConsoleApp1.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{7D920295-759D-4CFB-B58B-F6677971FD2F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7D920295-759D-4CFB-B58B-F6677971FD2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7D920295-759D-4CFB-B58B-F6677971FD2F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D920295-759D-4CFB-B58B-F6677971FD2F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7D920295-759D-4CFB-B58B-F6677971FD2F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/works/C#/Срез/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj b/works/C#/Срез/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj new file mode 100644 index 0000000..6c1dc92 --- /dev/null +++ b/works/C#/Срез/ConsoleApp1/ConsoleApp1/ConsoleApp1.csproj @@ -0,0 +1,10 @@ + + + + Exe + net10.0 + enable + enable + + + diff --git a/works/C#/Срез/ConsoleApp1/ConsoleApp1/Program.cs b/works/C#/Срез/ConsoleApp1/ConsoleApp1/Program.cs new file mode 100644 index 0000000..837131c --- /dev/null +++ b/works/C#/Срез/ConsoleApp1/ConsoleApp1/Program.cs @@ -0,0 +1 @@ +Console.WriteLine("Hello, World!"); \ No newline at end of file diff --git a/works/Lab(Kotlin)/lesson-5.1/untitled/.gitignore b/works/Lab(Kotlin)/lesson-5.1/untitled/.gitignore new file mode 100644 index 0000000..3ddbf4c --- /dev/null +++ b/works/Lab(Kotlin)/lesson-5.1/untitled/.gitignore @@ -0,0 +1,32 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Kotlin ### +.kotlin + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/works/Lab(Kotlin)/lesson-5.1/untitled/src/Main.kt b/works/Lab(Kotlin)/lesson-5.1/untitled/src/Main.kt new file mode 100644 index 0000000..7d671f6 --- /dev/null +++ b/works/Lab(Kotlin)/lesson-5.1/untitled/src/Main.kt @@ -0,0 +1,5 @@ +//TIP To Run code, press or +// click the icon in the gutter. +fun main() { + println("meow") +} \ No newline at end of file