From 68e01453e71d23fcc0741646166a41fb8f7963e0 Mon Sep 17 00:00:00 2001 From: User of DK12 Date: Tue, 30 Oct 2018 14:13:30 +0400 Subject: [PATCH 1/6] Laba2 Funkcia --- CourseApp/Program.cs | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 3f81738..8f5ba37 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,12 +1,42 @@ using System; -namespace CourseApp +namespace Matemat + { - class Program + public class Program { + public static double y(double x, double a, double b) + { + return (Math.Pow(a * x + b, 1 / 3) / (Math.Log10(x) * Math.Log10(x))); + } + static void Main(string[] args) { +<<<<<<< Updated upstream Console.WriteLine("Hello World!"); +======= + double a = 1.35; + double b = 0.98; + double xn = 1.14; + double xk = 4.24; + double dx = 0.62; + + double[] x = new double[5] { 0.35, 1.26, 0.37, 0.48, 0.56 }; + + Console.WriteLine("Задача A:"); + + for (double xl = xn; xl < xk; xl += dx) + { + Console.WriteLine($"Для x = {xl}\t y = {y(xl, a, b)}"); + } + + Console.WriteLine("Задача B:"); + + foreach (double i in x) + { + Console.WriteLine($"Для x = {i}\t y = {y(i, a, b)}"); + } +>>>>>>> Stashed changes } } -} +} \ No newline at end of file From 780e90da506863109c875d39eb773b16d53a4bed Mon Sep 17 00:00:00 2001 From: User of DK12 Date: Tue, 13 Nov 2018 14:00:48 +0400 Subject: [PATCH 2/6] Laba3Testi --- CourseApp.Tests/CourseApp.Tests.csproj | 24 +++++++ CourseApp.Tests/Program.cs | 39 ++++++++++++ CourseApp.Tests/UnitTest1.cs | 86 ++++++++++++++++++++++++++ CourseApp/CourseApp.csproj | 6 +- CourseApp/Program.cs | 7 +-- CourseApp/UnitTest1.cs | 86 ++++++++++++++++++++++++++ 6 files changed, 242 insertions(+), 6 deletions(-) create mode 100644 CourseApp.Tests/CourseApp.Tests.csproj create mode 100644 CourseApp.Tests/Program.cs create mode 100644 CourseApp.Tests/UnitTest1.cs create mode 100644 CourseApp/UnitTest1.cs diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj new file mode 100644 index 0000000..24ed50e --- /dev/null +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -0,0 +1,24 @@ + + + + netcoreapp2.0 + + false + + + + + + + + + + + + + + + + + + diff --git a/CourseApp.Tests/Program.cs b/CourseApp.Tests/Program.cs new file mode 100644 index 0000000..397bc7e --- /dev/null +++ b/CourseApp.Tests/Program.cs @@ -0,0 +1,39 @@ +using System; + +namespace Matem + +{ + public class Program + { + public static double y(double x, double a, double b) + { + return (Math.Pow(a * x + b, 1 / 3) / (Math.Log10(x) * Math.Log10(x))); + } + + static void Main(string[] args) + { + + double a = 1.35; + double b = 0.98; + double xn = 1.14; + double xk = 4.24; + double dx = 0.62; + + double[] x = new double[5] { 0.35, 1.26, 0.37, 0.48, 0.56 }; + + Console.WriteLine("Задача A:"); + + for (double xl = xn; xl < xk; xl += dx) + { + Console.WriteLine($"Для x = {xl}\t y = {y(xl, a, b)}"); + } + + Console.WriteLine("Задача B:"); + + foreach (double i in x) + { + Console.WriteLine($"Для x = {i}\t y = {y(i, a, b)}"); + } + } + } +} \ No newline at end of file diff --git a/CourseApp.Tests/UnitTest1.cs b/CourseApp.Tests/UnitTest1.cs new file mode 100644 index 0000000..9091a42 --- /dev/null +++ b/CourseApp.Tests/UnitTest1.cs @@ -0,0 +1,86 @@ +using System; +using Xunit; +using Matem; +namespace CourseApp.Tests +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + var res = Program.y(0, 0, 0); + Assert.Equal(0, res); + } + [Fact] + public void Test2() + { + var res = Program.y(2, 1, 4); + Assert.Equal(11.035, res, 3); + } + [Fact] + public void Test3() + { + var res = Program.y(4, 2, 1); + Assert.Equal(2.759, res, 3); + } + [Fact] + public void Test4() + { + var res = Program.y(5, 3, 2); + Assert.Equal(2.047, res, 3); + + } + [Fact] + public void Test5() + { + var res = Program.y(3, 0, 0); + Assert.Equal(4.393, res, 3); + + } + [Fact] + public void Test6() + { + var res = Program.y(7, 4, 2); + Assert.Equal(1.400, res, 3); + + } + [Fact] + public void Test7() + { + var res = Program.y(0, 5, 0); + Assert.Equal(0, res, 3); + + } + [Fact] + public void Test8() + { + var res = Program.y(0, 1, 0); + Assert.Equal(0, res, 3); + + } + [Fact] + public void Test9() + { + var res = Program.y(10, 0.1, 0); + Assert.Equal(1, res, 3); + + } + [Fact] + public void Test10() + { + var res = Program.y(0, 2, -1); + Assert.Equal(0, res, 3); + + } + [Fact] + public void Test11() + { + var res = Program.y(0, 0, 3); + Assert.Equal(0, res, 3); + + } + } + + + +} \ No newline at end of file diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index 23df604..fbd0c9d 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,7 +2,11 @@ Exe - netcoreapp2.1 + netcoreapp2.0 + + + + diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 8f5ba37..397bc7e 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,6 +1,6 @@ using System; -namespace Matemat +namespace Matem { public class Program @@ -12,9 +12,7 @@ public static double y(double x, double a, double b) static void Main(string[] args) { -<<<<<<< Updated upstream - Console.WriteLine("Hello World!"); -======= + double a = 1.35; double b = 0.98; double xn = 1.14; @@ -36,7 +34,6 @@ static void Main(string[] args) { Console.WriteLine($"Для x = {i}\t y = {y(i, a, b)}"); } ->>>>>>> Stashed changes } } } \ No newline at end of file diff --git a/CourseApp/UnitTest1.cs b/CourseApp/UnitTest1.cs new file mode 100644 index 0000000..f17b4f3 --- /dev/null +++ b/CourseApp/UnitTest1.cs @@ -0,0 +1,86 @@ +using System; +using Xunit; +using Matem; +namespace CourseApp.Tests +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + var res = Program.y(0, 0, 0); + Assert.Equal(0, res); + } + [Fact] + public void Test2() + { + var res = Program.y(2, 1, 4); + Assert.Equal(11.035, res, 3); + } + [Fact] + public void Test3() + { + var res = Program.y(4, 2, 1); + Assert.Equal(2.759, res, 3); + } + [Fact] + public void Test4() + { + var res = Program.y(5, 3, 2); + Assert.Equal(2.047, res, 3); + + } + [Fact] + public void Test5() + { + var res = Program.y(3, 0, 0); + Assert.Equal(4.393, res, 3); + + } + [Fact] + public void Test6() + { + var res = Program.y(7, 4, 2); + Assert.Equal(1.400, res, 3); + + } + [Fact] + public void Test7() + { + var res = Program.y(0, 5, 0); + Assert.Equal(Double.NaN, res); + + } + [Fact] + public void Test8() + { + var res = Program.y(0, 1, 0); + Assert.Equal(Double.NaN, res); + + } + [Fact] + public void Test9() + { + var res = Program.y(10, 0.1, 0); + Assert.Equal(1.395, res, 3); + + } + [Fact] + public void Test10() + { + var res = Program.y(20, 0, -1); + Assert.Equal(Double.PositiveInfinity, res); + + } + [Fact] + public void Test11() + { + var res = Program.y(-1, 1, -1); + Assert.Equal(Double.NegativeInfinity, res); + + } + } + + + +} \ No newline at end of file From 7053d51fac3e3e96397f78ed79888306ea431558 Mon Sep 17 00:00:00 2001 From: User of DK12 Date: Tue, 13 Nov 2018 14:35:20 +0400 Subject: [PATCH 3/6] Laba3Tests --- CourseApp.Tests/Program.cs | 39 ---------------- CourseApp.Tests/UnitTest1.cs | 12 ++--- CourseApp/Program.cs | 2 +- CourseApp/UnitTest1.cs | 86 ------------------------------------ 4 files changed, 7 insertions(+), 132 deletions(-) delete mode 100644 CourseApp.Tests/Program.cs delete mode 100644 CourseApp/UnitTest1.cs diff --git a/CourseApp.Tests/Program.cs b/CourseApp.Tests/Program.cs deleted file mode 100644 index 397bc7e..0000000 --- a/CourseApp.Tests/Program.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; - -namespace Matem - -{ - public class Program - { - public static double y(double x, double a, double b) - { - return (Math.Pow(a * x + b, 1 / 3) / (Math.Log10(x) * Math.Log10(x))); - } - - static void Main(string[] args) - { - - double a = 1.35; - double b = 0.98; - double xn = 1.14; - double xk = 4.24; - double dx = 0.62; - - double[] x = new double[5] { 0.35, 1.26, 0.37, 0.48, 0.56 }; - - Console.WriteLine("Задача A:"); - - for (double xl = xn; xl < xk; xl += dx) - { - Console.WriteLine($"Для x = {xl}\t y = {y(xl, a, b)}"); - } - - Console.WriteLine("Задача B:"); - - foreach (double i in x) - { - Console.WriteLine($"Для x = {i}\t y = {y(i, a, b)}"); - } - } - } -} \ No newline at end of file diff --git a/CourseApp.Tests/UnitTest1.cs b/CourseApp.Tests/UnitTest1.cs index 9091a42..8f2ebe8 100644 --- a/CourseApp.Tests/UnitTest1.cs +++ b/CourseApp.Tests/UnitTest1.cs @@ -15,33 +15,33 @@ public void Test1() public void Test2() { var res = Program.y(2, 1, 4); - Assert.Equal(11.035, res, 3); + Assert.Equal(20.052, res, 3); } [Fact] public void Test3() { var res = Program.y(4, 2, 1); - Assert.Equal(2.759, res, 3); + Assert.Equal(5.739, res, 3); } [Fact] public void Test4() { var res = Program.y(5, 3, 2); - Assert.Equal(2.047, res, 3); + Assert.Equal(5.263, res, 3); } [Fact] public void Test5() { var res = Program.y(3, 0, 0); - Assert.Equal(4.393, res, 3); + Assert.Equal(0, res, 3); } [Fact] public void Test6() { var res = Program.y(7, 4, 2); - Assert.Equal(1.400, res, 3); + Assert.Equal(4.351, res, 3); } [Fact] @@ -68,7 +68,7 @@ public void Test9() [Fact] public void Test10() { - var res = Program.y(0, 2, -1); + var res = Program.y(0, 2, 3); Assert.Equal(0, res, 3); } diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 397bc7e..1914879 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -7,7 +7,7 @@ public class Program { public static double y(double x, double a, double b) { - return (Math.Pow(a * x + b, 1 / 3) / (Math.Log10(x) * Math.Log10(x))); + return (Math.Pow(a * x + b, 1 / 3.0) / (Math.Log10(x) * Math.Log10(x))); } static void Main(string[] args) diff --git a/CourseApp/UnitTest1.cs b/CourseApp/UnitTest1.cs deleted file mode 100644 index f17b4f3..0000000 --- a/CourseApp/UnitTest1.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using Xunit; -using Matem; -namespace CourseApp.Tests -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - var res = Program.y(0, 0, 0); - Assert.Equal(0, res); - } - [Fact] - public void Test2() - { - var res = Program.y(2, 1, 4); - Assert.Equal(11.035, res, 3); - } - [Fact] - public void Test3() - { - var res = Program.y(4, 2, 1); - Assert.Equal(2.759, res, 3); - } - [Fact] - public void Test4() - { - var res = Program.y(5, 3, 2); - Assert.Equal(2.047, res, 3); - - } - [Fact] - public void Test5() - { - var res = Program.y(3, 0, 0); - Assert.Equal(4.393, res, 3); - - } - [Fact] - public void Test6() - { - var res = Program.y(7, 4, 2); - Assert.Equal(1.400, res, 3); - - } - [Fact] - public void Test7() - { - var res = Program.y(0, 5, 0); - Assert.Equal(Double.NaN, res); - - } - [Fact] - public void Test8() - { - var res = Program.y(0, 1, 0); - Assert.Equal(Double.NaN, res); - - } - [Fact] - public void Test9() - { - var res = Program.y(10, 0.1, 0); - Assert.Equal(1.395, res, 3); - - } - [Fact] - public void Test10() - { - var res = Program.y(20, 0, -1); - Assert.Equal(Double.PositiveInfinity, res); - - } - [Fact] - public void Test11() - { - var res = Program.y(-1, 1, -1); - Assert.Equal(Double.NegativeInfinity, res); - - } - } - - - -} \ No newline at end of file From 25e7bfe033107b1cd573bb4a87a5d4af821e1c95 Mon Sep 17 00:00:00 2001 From: User of DK12 Date: Tue, 25 Dec 2018 14:02:21 +0400 Subject: [PATCH 4/6] Laba Class FOX --- CourseApp.Tests/FoxTest.cs | 73 +++++++++++++++++++++++++++++++ CourseApp/CourseApp.csproj | 6 +-- CourseApp/CourseApp.sln | 31 +++++++++++++ CourseApp/Fox.cs | 90 ++++++++++++++++++++++++++++++++++++++ CourseApp/Program.cs | 11 ++++- 5 files changed, 204 insertions(+), 7 deletions(-) create mode 100644 CourseApp.Tests/FoxTest.cs create mode 100644 CourseApp/CourseApp.sln create mode 100644 CourseApp/Fox.cs diff --git a/CourseApp.Tests/FoxTest.cs b/CourseApp.Tests/FoxTest.cs new file mode 100644 index 0000000..be96d91 --- /dev/null +++ b/CourseApp.Tests/FoxTest.cs @@ -0,0 +1,73 @@ +using System; +using Xunit; +using Fauna; + +namespace CourseApp.Tests +{ + public class FoxTest + { + [Fact] + public void Test1() + { + Fox africa = new Fox("Neznaem", "White", 25, 30); + Assert.Equal("Unknow", africa.Gender); + Assert.Equal("White", africa.Color); + Assert.Equal(25, africa.Weight); + Assert.Equal(30, africa.Growth); + } + + [Fact] + public void Test2() + { + Fox europe = new Fox("Female", -15); + Assert.Equal("Female", europe.Gender); + Assert.Equal(0, europe.Weight); + } + + [Fact] + public void Test3() + { + Fox europe = new Fox("Koshka", -3); + Assert.Equal("Unknow", europe.Gender); + Assert.Equal(0, europe.Weight); + } + + [Fact] + public void Test4() + { + Fox europe = new Fox("Male", 28); + Assert.Equal("Male", europe.Gender); + Assert.Equal(28, europe.Weight); + } + + [Fact] + public void Test5() + { + Fox africa = new Fox("Male", "Blond", 13, -5); + Assert.Equal("Male", africa.Gender); + Assert.Equal("Blond", africa.Color); + Assert.Equal(13, africa.Weight); + Assert.Equal(0, africa.Growth); + } + + [Fact] + public void Test6() + { + Fox africa = new Fox("Neznaem", "", -25, -30); + Assert.Equal("Unknow", africa.Gender); + Assert.Equal("UnknowColor", africa.Color); + Assert.Equal(0, africa.Weight); + Assert.Equal(0, africa.Growth); + } + + [Fact] + public void Test7() + { + Fox africa = new Fox("Male", "555", 15, 20); + Assert.Equal("Male", africa.Gender); + Assert.Equal("UnknowColor", africa.Color); + Assert.Equal(15, africa.Weight); + Assert.Equal(20, africa.Growth); + } + } +} \ No newline at end of file diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index fbd0c9d..a8d5796 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -1,12 +1,8 @@ - + Exe netcoreapp2.0 - - - - diff --git a/CourseApp/CourseApp.sln b/CourseApp/CourseApp.sln new file mode 100644 index 0000000..23ea1c4 --- /dev/null +++ b/CourseApp/CourseApp.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.168 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp", "CourseApp.csproj", "{C95F0266-E3E5-484C-858A-D4C61EC6A4AA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "..\CourseApp.Tests\CourseApp.Tests.csproj", "{22805653-2FE6-40B8-B856-4D9884187751}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C95F0266-E3E5-484C-858A-D4C61EC6A4AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C95F0266-E3E5-484C-858A-D4C61EC6A4AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C95F0266-E3E5-484C-858A-D4C61EC6A4AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C95F0266-E3E5-484C-858A-D4C61EC6A4AA}.Release|Any CPU.Build.0 = Release|Any CPU + {22805653-2FE6-40B8-B856-4D9884187751}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {22805653-2FE6-40B8-B856-4D9884187751}.Debug|Any CPU.Build.0 = Debug|Any CPU + {22805653-2FE6-40B8-B856-4D9884187751}.Release|Any CPU.ActiveCfg = Release|Any CPU + {22805653-2FE6-40B8-B856-4D9884187751}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0DEB2E85-CECB-44FB-B010-E7DF83EC7B26} + EndGlobalSection +EndGlobal diff --git a/CourseApp/Fox.cs b/CourseApp/Fox.cs new file mode 100644 index 0000000..0e8bd7e --- /dev/null +++ b/CourseApp/Fox.cs @@ -0,0 +1,90 @@ +using System; + +namespace Fauna +{ + public class Fox + { + private string gender; + private string color; + private int weight; + private int growth; + + public Fox(string gender, string color, int weight, int growth) + { + if (gender == $"Male") + { + Gender = gender; + } + else if (gender == $"Female") + { + Gender = gender; + } + else + { + Gender = $"Unknow"; + } + if (color == $"White") + { + Color = color; + } + else if (color == $"Blond") + { + Color = color; + } + else if (color == $"Red") + + { + Color = color; + } + else if (color == string.Empty) + { + Color = $"UnknowColor"; + } + else + { + Color = $"UnknowColor"; + } + + this.Weight = weight; + this.Growth = growth; + } + + public Fox(string gender, int weight) + : this(gender, string.Empty, weight, 0) + { + } + + public string Gender + { + get => gender; + set => gender = value; + + } + + public string Color + { + get => color; + set => color = value; + } + + public int Weight + { + get => weight; + set + { + weight = value > 0 ? value : 0; + } + } + + public int Growth + { + get => growth; + set + { + growth = value > 0 ? value : 0; + } + } + + public void GetInfo() => Console.WriteLine($"Пол: {gender} Цвет: {color} Вес: {weight} Рост: {growth}"); + } +} \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 1914879..0cefa17 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,5 +1,5 @@ using System; - +using Fauna; namespace Matem { @@ -34,6 +34,13 @@ static void Main(string[] args) { Console.WriteLine($"Для x = {i}\t y = {y(i, a, b)}"); } + + Fox africa = new Fox($"Male", $"White", 25, 30); + Fox europe = new Fox($"Female", 15); + africa.GetInfo(); + europe.GetInfo(); + + Console.ReadKey(); } } -} \ No newline at end of file +} From 1b34e5932719ea07099f302835806ed30ef2c2a4 Mon Sep 17 00:00:00 2001 From: User of DK12 Date: Tue, 25 Dec 2018 15:04:47 +0400 Subject: [PATCH 5/6] Laba 3 Class FOX --- CourseApp/Fox.cs | 82 +++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/CourseApp/Fox.cs b/CourseApp/Fox.cs index 0e8bd7e..0dd4f6f 100644 --- a/CourseApp/Fox.cs +++ b/CourseApp/Fox.cs @@ -11,40 +11,10 @@ public class Fox public Fox(string gender, string color, int weight, int growth) { - if (gender == $"Male") - { - Gender = gender; - } - else if (gender == $"Female") - { - Gender = gender; - } - else - { - Gender = $"Unknow"; - } - if (color == $"White") - { - Color = color; - } - else if (color == $"Blond") - { - Color = color; - } - else if (color == $"Red") - { - Color = color; - } - else if (color == string.Empty) - { - Color = $"UnknowColor"; - } - else - { - Color = $"UnknowColor"; - } - + + this.Gender = gender; + this.Color = color; this.Weight = weight; this.Growth = growth; } @@ -57,14 +27,54 @@ public Fox(string gender, int weight) public string Gender { get => gender; - set => gender = value; - + set + { + if (value == $"Male") + { + gender = value; + } + else if (value == $"Female") + { + gender = value; + } + else + { + gender = $"Unknow"; + } + + } + + } public string Color { get => color; - set => color = value; + set + { + if (value == $"White") + { + color = value; + } + else if (value == $"Blond") + { + color = value; + } + else if (value == $"Red") + + { + color = value; + } + else if (value == string.Empty) + { + color = $"UnknowColor"; + } + else + { + color = $"UnknowColor"; + } + + } } public int Weight From bd9e1a90938b88e5f34fe99098d6b5ac5d28f79c Mon Sep 17 00:00:00 2001 From: User of DK12 Date: Tue, 25 Dec 2018 15:14:37 +0400 Subject: [PATCH 6/6] Laba FoxClassNew --- CourseApp/Program.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index aba101a..1307d9e 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,6 +1,5 @@ using System; using Fauna; -namespace Matem namespace Matem