diff --git a/CourseApp.Tests/Class1.cs b/CourseApp.Tests/Class1.cs new file mode 100644 index 0000000..41e9d79 --- /dev/null +++ b/CourseApp.Tests/Class1.cs @@ -0,0 +1,25 @@ +using System; +using Xunit; +using ConsoleApp2; +namespace CourseApp.Tests +{ + public class UnitTest2 + { + [Fact] + public void CheckSecondKonstruktor1() + { + Car car2 = new Car("tesla", 230); + Assert.Equal("tesla", car2.Name); + Assert.Equal(230, car2.Speed); + + } + [Fact] + public void CheckSecondKonstruktor2() + { + Car car2 = new Car("zhigul", 155); + Assert.Equal("zhigul", car2.Name); + Assert.Equal(155, car2.Speed); + + } + } +} \ No newline at end of file diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj new file mode 100644 index 0000000..98432ca --- /dev/null +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -0,0 +1,30 @@ + + + + netcoreapp2.0 + True + 1573,1591,1701;1702;1705 + false + + + + + + + + + + + + + + + ../stylecop/stylecop.ruleset + true + + + + + + + diff --git a/CourseApp.Tests/CourseApp.Tests.sln b/CourseApp.Tests/CourseApp.Tests.sln new file mode 100644 index 0000000..fa00fff --- /dev/null +++ b/CourseApp.Tests/CourseApp.Tests.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2002 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "CourseApp.Tests.csproj", "{7E619433-E12F-45F9-BC3B-B9C0162C5D5F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7E619433-E12F-45F9-BC3B-B9C0162C5D5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7E619433-E12F-45F9-BC3B-B9C0162C5D5F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7E619433-E12F-45F9-BC3B-B9C0162C5D5F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7E619433-E12F-45F9-BC3B-B9C0162C5D5F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5689BE8B-26B5-4E2F-BDCD-8285FB088509} + EndGlobalSection +EndGlobal diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs new file mode 100644 index 0000000..09e415e --- /dev/null +++ b/CourseApp.Tests/DemoTest.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace CourseApp.Tests +{ + public class DemoTest + { + [Fact] + public void Test1() + { + Assert.True(true); + } + } +} diff --git a/CourseApp.Tests/UnitTest1.cs b/CourseApp.Tests/UnitTest1.cs new file mode 100644 index 0000000..71a191e --- /dev/null +++ b/CourseApp.Tests/UnitTest1.cs @@ -0,0 +1,41 @@ +using System; +using Xunit; +using Matan; + + +namespace CourseApp.Tests +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + var res = Program.y(1); + Assert.Equal(5.0625 , res); + } + [Fact] + public void Test2() + { + var res = Program.y(-1); + Assert.Equal(5.06215, res, 3); + } + [Fact] + public void Test3() + { + var res = Program.y(1.25); + Assert.Equal(0.78, res,3); + } + [Fact] + public void Test4() + { + var res = Program.y(2.89); + Assert.Equal(1173.645, res, 3); + } + [Fact] + public void Test5() + { + var res = Program.y(-3.55); + Assert.Equal(10417.68, res, 3); + } + } +} diff --git a/CourseApp/Class11.cs b/CourseApp/Class11.cs new file mode 100644 index 0000000..99fee9c --- /dev/null +++ b/CourseApp/Class11.cs @@ -0,0 +1,55 @@ +using System; + +namespace ConsoleApp2 +{ + using System; + + public class Class11 + { + private string name; + private int speed; + + public Class11(string name, int speed) + { + this.name = name; + this.speed = speed; + } + + public Class11(int speed) + { + name = "Noname"; + this.speed = speed; + } + + public string Name + { + get + { + return name; + } + + set => name = value; + } + + public int Speed + { + get + { + return speed; + } + + set + { + if (value > 0) + { + speed = value; + } + } + } + + public string GetInfo() + { + return $"Имя: {name} скорость: {speed} "; + } + } +} \ No newline at end of file diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index 23df604..1d3d391 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,7 +2,23 @@ Exe - netcoreapp2.1 + netcoreapp2.0 + True + 1573,1591,1701;1702;1705 + + + + + + + + + ../stylecop/stylecop.ruleset + true + + + + diff --git a/CourseApp/CourseApp.sln b/CourseApp/CourseApp.sln new file mode 100644 index 0000000..ce764fa --- /dev/null +++ b/CourseApp/CourseApp.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2002 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp", "CourseApp.csproj", "{3C2630FF-B548-4F7A-AD39-F42BFAE79DE2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3C2630FF-B548-4F7A-AD39-F42BFAE79DE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C2630FF-B548-4F7A-AD39-F42BFAE79DE2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C2630FF-B548-4F7A-AD39-F42BFAE79DE2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C2630FF-B548-4F7A-AD39-F42BFAE79DE2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7CF6A1A5-9351-446B-A4AA-EFF0A9D65034} + EndGlobalSection +EndGlobal diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 3f81738..1de4997 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,12 +1,34 @@ using System; -namespace CourseApp +namespace Matan { - class Program + public class Program { - static void Main(string[] args) + public static double Y(double x) { - Console.WriteLine("Hello World!"); + return Math.Pow(x: Math.Abs((x * x) - 2.5), y: 4.0) + Math.Pow(Math.Log10(x * x), 3.0); + } + + private static void Main(string[] args) + { + double xn = 1.25; + double xk = 3.25; + double dx = 0.4; + + double[] x = new double[5] { 1.84, 2.71, 3.81, 4.56, 5.62 }; + + Console.WriteLine("Задача A:"); + for (double xl = xn; xl < xk; xl += dx) + { + Console.WriteLine($"Для x = {xl}\t y = {Y(xl)}"); + } + + Console.WriteLine("Задача B:"); + + foreach (double i in x) + { + Console.WriteLine($"Для x = {i}\t y = {Y(i)}"); + } } } } diff --git a/README.md b/README.md index ee1aa8c..010e75a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1 @@ -# Course of c# - -Please write your name and surname here \ No newline at end of file +Jurij_Kochnev \ No newline at end of file diff --git a/stylecop/stylecop.json b/stylecop/stylecop.json new file mode 100644 index 0000000..643b8c1 --- /dev/null +++ b/stylecop/stylecop.json @@ -0,0 +1,15 @@ +{ + "$schema": + "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", + "settings": { + "documentationRules": { + "documentExposedElements": false, + "documentInterfaces": false, + "companyName": "Test Company", + "copyrightText": + "This source code is Copyright © {companyName} and MAY NOT be copied, reproduced,\npublished, distributed or transmitted to or stored in any manner without prior\nwritten consent from {companyName} (www.yourcompany.com).", + "xmlHeader": false + } + }, + "additionalArguments": ["./stylecop.ruleset", "./stylecop.json"] +} diff --git a/stylecop/stylecop.ruleset b/stylecop/stylecop.ruleset new file mode 100644 index 0000000..3350d0e --- /dev/null +++ b/stylecop/stylecop.ruleset @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file