From aeb27bc23b08cdf09d3f75540aef1d1c06e6c7f9 Mon Sep 17 00:00:00 2001 From: Eugeny Konstantinov Date: Thu, 10 Oct 2019 09:39:40 +0300 Subject: [PATCH 01/41] Sample of 1st lab --- CourseApp/Program.cs | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 248bbe4..11e476f 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -4,9 +4,61 @@ namespace CourseApp { public class Program { + public static double MyFunction(double a, double b, double x) + { + var c = (b * x) + a; + return c; + } + + public static double[] TaskA ( + double a, + double b, + double xn, + double xk, + double dx) + { + var steps = (int)Math.Floor((xk - xn) / dx); + var y = new double[steps]; + var i = 0; + for (var x = xn; x < xk; x += dx) + { + y[i] = MyFunction(a, b, x); + i++; + } + + return y; + } + + public static double[] TaskB ( + double a, + double b, + double[] x) + { + var y = new double[x.Length]; + for (int i = 0; i < x.Length; i++) + { + y[i] = MyFunction(a, b, x[i]); + } + + return y; + } + public static void Main(string[] args) { Console.WriteLine("Hello World!"); + var taskA = TaskA(2, 3, 0, 5, 1); + for (var i = 0; i < taskA.Length; i++) + { + Console.WriteLine($"y={taskA[i]}"); + } + + var xB = new double[] { 0, 1, 2, 3 }; + var taskB = TaskB(2, 3, xB); + for (var i = 0; i < xB.Length; i++) + { + Console.WriteLine($"x={xB[i]} y={taskB[i]}"); + } + Console.ReadLine(); } } From 02472201c8e437f910a9fcd8e11ad50403aae5fa Mon Sep 17 00:00:00 2001 From: Eugeny Konstantinov Date: Thu, 17 Oct 2019 09:32:31 +0300 Subject: [PATCH 02/41] Tests samples --- CourseApp.Tests/DemoTest.cs | 25 +++++++++++++++++++++++-- CourseApp/CourseApp.sln | 31 +++++++++++++++++++++++++++++++ CourseApp/Program.cs | 4 +++- 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 CourseApp/CourseApp.sln diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs index fdc46f5..bd31c5c 100644 --- a/CourseApp.Tests/DemoTest.cs +++ b/CourseApp.Tests/DemoTest.cs @@ -5,10 +5,31 @@ namespace CourseApp.Tests { public class DemoTest { + [Theory] + [InlineData(0, 0, 0, double.NaN)] + [InlineData(1, 1, 2, 2.5)] + [InlineData(-1, 1, 1, 0)] + public void TestCalc(double a, double b, double x, double exp) + { + var res = Program.MyFunction(a, b, x); + Assert.Equal(exp, res, 3); + } + + [Fact] + public void TestNormalA() + { + } + + [Fact] + public void TestNormalB() + { + } + [Fact] - public void Test1() + public void TestZeroLengthB() { - Assert.True(true); + var res = Program.TaskB(1, 1, new double[0]); + Assert.Empty(res); } } } diff --git a/CourseApp/CourseApp.sln b/CourseApp/CourseApp.sln new file mode 100644 index 0000000..3dac3f4 --- /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.852 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp", "CourseApp.csproj", "{17CB0273-34D3-4D23-965F-FC4AD0A83D0F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "..\CourseApp.Tests\CourseApp.Tests.csproj", "{E0133767-62A2-4B4A-87A2-BD09BC775E0A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {17CB0273-34D3-4D23-965F-FC4AD0A83D0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17CB0273-34D3-4D23-965F-FC4AD0A83D0F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17CB0273-34D3-4D23-965F-FC4AD0A83D0F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17CB0273-34D3-4D23-965F-FC4AD0A83D0F}.Release|Any CPU.Build.0 = Release|Any CPU + {E0133767-62A2-4B4A-87A2-BD09BC775E0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0133767-62A2-4B4A-87A2-BD09BC775E0A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0133767-62A2-4B4A-87A2-BD09BC775E0A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0133767-62A2-4B4A-87A2-BD09BC775E0A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1849B280-B447-4D18-9764-F412B7768C4F} + EndGlobalSection +EndGlobal diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 11e476f..e887881 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -6,7 +6,7 @@ public class Program { public static double MyFunction(double a, double b, double x) { - var c = (b * x) + a; + var c = (b * x) + (a / x); return c; } @@ -47,6 +47,8 @@ public static void Main(string[] args) { Console.WriteLine("Hello World!"); var taskA = TaskA(2, 3, 0, 5, 1); + Console.WriteLine(taskA); + for (var i = 0; i < taskA.Length; i++) { Console.WriteLine($"y={taskA[i]}"); From d514055c9f7c9797067e4a2a8d7c641baa08abe6 Mon Sep 17 00:00:00 2001 From: Eugeny Konstantinov Date: Thu, 24 Oct 2019 08:32:42 +0300 Subject: [PATCH 03/41] Added actions file --- .github/workflows/dotnetcore.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/dotnetcore.yml diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml new file mode 100644 index 0000000..9c411d0 --- /dev/null +++ b/.github/workflows/dotnetcore.yml @@ -0,0 +1,23 @@ +name: .NET Core + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 2.1.802 + - name: Build with dotnet + run: + cd CourseApp + dotnet build --configuration Release + - name: Run tests + run: + cd CourseApp.Tests + dotnet test From b29aa6068fc4563d806b34b69b12709aa396960b Mon Sep 17 00:00:00 2001 From: Eugeny Konstantinov Date: Thu, 24 Oct 2019 08:37:06 +0300 Subject: [PATCH 04/41] Fixed run steps (#28) --- .github/workflows/dotnetcore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 9c411d0..a09addb 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -14,10 +14,10 @@ jobs: with: dotnet-version: 2.1.802 - name: Build with dotnet - run: + run: | cd CourseApp dotnet build --configuration Release - name: Run tests - run: + run: | cd CourseApp.Tests dotnet test From dbae387a93373aae5ee85254037203dd830c012b Mon Sep 17 00:00:00 2001 From: Eugeny Konstantinov Date: Thu, 24 Oct 2019 09:25:23 +0300 Subject: [PATCH 05/41] Test actions on PR (#30) --- .github/workflows/dotnetcore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index a09addb..22cc4eb 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -1,6 +1,6 @@ name: .NET Core -on: [push] +on: [push, pull_request] jobs: build: From 953427ebb4df2222f1edbd3967812883ed4ecb0a Mon Sep 17 00:00:00 2001 From: Eugeny Konstantinov Date: Thu, 24 Oct 2019 09:28:33 +0300 Subject: [PATCH 06/41] Added tests and sample A|B tasks --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 556d11d..b422454 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# Tprogramming_147_2019 \ No newline at end of file +# Tprogramming_147_2019 +Konstantinov Eugeny \ No newline at end of file From 62b5d9ec96a03500857576f39c0a2aabe5aa348f Mon Sep 17 00:00:00 2001 From: Eugeny Konstantinov Date: Thu, 7 Nov 2019 09:14:46 +0300 Subject: [PATCH 07/41] Added class task example, added vscode conf --- .gitignore | 1 - CourseApp.Tests/PlatypusTest.cs | 55 ++++++++++++++++++++++++++++++ CourseApp/.vscode/launch.json | 25 ++++++++++++++ CourseApp/.vscode/tasks.json | 42 +++++++++++++++++++++++ CourseApp/Platypus.cs | 60 +++++++++++++++++++++++++++++++++ CourseApp/Program.cs | 3 ++ 6 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 CourseApp.Tests/PlatypusTest.cs create mode 100644 CourseApp/.vscode/launch.json create mode 100644 CourseApp/.vscode/tasks.json create mode 100644 CourseApp/Platypus.cs diff --git a/.gitignore b/.gitignore index 35d4ccd..24cb440 100644 --- a/.gitignore +++ b/.gitignore @@ -198,7 +198,6 @@ $RECYCLE.BIN/ **/node_modules/* # Added by Jskonst -.vscode/ Properties/ ##### diff --git a/CourseApp.Tests/PlatypusTest.cs b/CourseApp.Tests/PlatypusTest.cs new file mode 100644 index 0000000..77c4d8f --- /dev/null +++ b/CourseApp.Tests/PlatypusTest.cs @@ -0,0 +1,55 @@ +using System; +using Xunit; + +namespace CourseApp.Tests +{ + public class PlatypusTest + { + [Fact] + public void TestEmptyConstructor() + { + var item = new Platypus(); + Assert.Equal(0, item.Age); + Assert.Equal("Untitled", item.Name); + Assert.True(item.IsMale); + } + + [Fact] + public void TestView() + { + var item = new Platypus(); + var view = @" + _.-^~~^^^`~-,_,,~''''''```~,''``~'``~, + ______,' -o :. _ . ; ,'`, `. +( -\.._,.;;'._ ,( } _`_-_,, `, `, + ``~~~~~~' ((/'((((____/~~~~~~'(,(,___> `~' + "; + Assert.Equal(view, item.View()); + } + + [Fact] + public void TestSetAge() + { + var item = new Platypus(); + item.Age = 5; + Assert.Equal(5, item.Age); + } + + [Fact] + public void TestIncorrectSetAge() + { + var item = new Platypus(); + item.Age = -5; + Assert.Equal(0, item.Age); + } + + [Fact] + public void TestCorrectIncorrectSetAge() + { + var item = new Platypus(); + item.Age = 10; + item.Age = -5; + Assert.Equal(10, item.Age); + } + } +} diff --git a/CourseApp/.vscode/launch.json b/CourseApp/.vscode/launch.json new file mode 100644 index 0000000..208ea3a --- /dev/null +++ b/CourseApp/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.1/CourseApp.dll", + "args": [], + "cwd": "${workspaceFolder}", + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/CourseApp/.vscode/tasks.json b/CourseApp/.vscode/tasks.json new file mode 100644 index 0000000..f8c71cd --- /dev/null +++ b/CourseApp/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/CourseApp.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/CourseApp.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/CourseApp.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/CourseApp/Platypus.cs b/CourseApp/Platypus.cs new file mode 100644 index 0000000..eb3d463 --- /dev/null +++ b/CourseApp/Platypus.cs @@ -0,0 +1,60 @@ +using System; + +namespace CourseApp +{ + public class Platypus + { + private int age; + + public Platypus() + : this(0, "Untitled", true) + { + } + + public Platypus(int age, string name, bool isMale) + { + Name = name; + Age = age; + IsMale = isMale; + } + + public string Name { get; set; } + + public int Age + { + get + { + return this.age; + } + + set + { + if (value >= 0 && value < 20) + { + this.age = value; + } + else + { + Console.WriteLine("Age should be > 0 and < than 20"); + } + } + } + + public bool IsMale { get; set; } + + public bool IsPoisoned + { + get { return this.IsMale; } + } + + public string View() + { + return @" + _.-^~~^^^`~-,_,,~''''''```~,''``~'``~, + ______,' -o :. _ . ; ,'`, `. +( -\.._,.;;'._ ,( } _`_-_,, `, `, + ``~~~~~~' ((/'((((____/~~~~~~'(,(,___> `~' + "; + } + } +} \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index e887881..a43396c 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -61,6 +61,9 @@ public static void Main(string[] args) Console.WriteLine($"x={xB[i]} y={taskB[i]}"); } + var item = new Platypus(); + Console.WriteLine(item.View()); + Console.ReadLine(); } } From 60071cf1e04e0536fc1630cc74c1c1ee74055289 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Thu, 14 Nov 2019 14:27:37 +0300 Subject: [PATCH 08/41] lab --- CourseApp.Tests/CourseApp.Tests.csproj | 16 ++-------- CourseApp.Tests/DemoTest.cs | 34 +++++++++++++++++++-- CourseApp/CourseApp.csproj | 2 +- CourseApp/Program.cs | 42 +++++++++++++++++++++++++- 4 files changed, 76 insertions(+), 18 deletions(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 8fb7e4a..7a6bfb0 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -2,29 +2,19 @@ netcoreapp2.1 - True - 1573,1591,1701;1702;1705 + false - + - + - - ../_stylecop/stylecop.ruleset - true - - - - - - diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs index fdc46f5..f11b76a 100644 --- a/CourseApp.Tests/DemoTest.cs +++ b/CourseApp.Tests/DemoTest.cs @@ -5,10 +5,38 @@ namespace CourseApp.Tests { public class DemoTest { - [Fact] - public void Test1() + [Theory] + [InlineData(2.0, 1.2, 4.2, 0.6)] + public void TestTaskA(double a, double xn, double xk, double dx) { - Assert.True(true); + var resultA = Program.TaskA(a, xn, xk, dx); + Assert.Equal(resultA, new double[0]); } + [Theory] + [InlineData(2.0, 1.2, 4.2, 0.6)] + public void Test(double a, double xn, double xk, double dx) + { + int k = 0; + var resultA = Program.TaskA(a, xn, xk, dx); + var result = new int[resultA.Length]; + foreach (var item in resultA) + { + result[k] = (int)Math.Floor(resA[k]); + k++; + } + var exp = new int[] {24, 23, 21, 19, 17}; + Assert.Equal(result, exp, 3); + } + [Theory] + public void TestTaskB() + { + var mass = new double[] { 1.16, 1.32, 1.47, 1.65, 1.93 }; + var resultB = Program.TaskB(2.0, mass); + var expy = new double[] { 0.0250047248573638, 0.0246393618709823, 0.0242470198513219, 0.0237322773817727, 0.0228750269630625} + for (int i = 0; i < 5; i++) + { + Assert.Equal(expy[i], resultB[i], 3); + } + } } } diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index b244e47..dffae8d 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.1 + netcoreapp2.0 True 1573,1591,1701;1702;1705; diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 248bbe4..fbe0237 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -4,9 +4,49 @@ namespace CourseApp { public class Program { + public static double[] TaskA(double a, double xn, double xk, double dx) + { + int k = 0; + var y = new double[5]; + for (var i = xn; i < xk; i += dx) + { + y[k] = Math.Pow(Math.Log10(a + i), 2) / Math.Pow(a + i, 2); + k++; + } + return y; + } + + public static double[] TaskB(double a, double[] x) + { + var y = new double[x.Length]; + for (var i = 0; i < y.Length; i++) + { + y[i] = Math.Pow(Math.Log10(a + x[i]), 2) / Math.Pow(a + x[i], 2); + } + return y; + } + public static void Main(string[] args) { - Console.WriteLine("Hello World!"); + double a = 2.0; + double xn = 1.2; + double xk = 4.2; + double dx = 0.6; + + var resSingle = TaskA(a, xn, xk, dx); + Console.WriteLine("Задание А:"); + foreach (var item in resSingle) + { + Console.WriteLine($"y = {item}"); + } + + var x = new double[] { 1.16, 1.32, 1.47, 1.65, 1.93 }; + var taskBRes = TaskB(a, x); + Console.WriteLine("Задание В:"); + foreach (var item in taskBRes) + { + Console.WriteLine($"y1 = {item}"); + } Console.ReadLine(); } } From 178c0e08c05f102f8639f1ca219a02c3061c4e21 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Thu, 14 Nov 2019 14:33:14 +0300 Subject: [PATCH 09/41] lab1.1 --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- CourseApp.Tests/DemoTest.cs | 21 ++++++++------- CourseApp/Program.cs | 37 ++++++++++++-------------- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 7a6bfb0..4c873c5 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -2,7 +2,7 @@ netcoreapp2.1 - + 1573,1591,1701;1702;1705 false diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs index f11b76a..f40a002 100644 --- a/CourseApp.Tests/DemoTest.cs +++ b/CourseApp.Tests/DemoTest.cs @@ -6,11 +6,11 @@ namespace CourseApp.Tests public class DemoTest { [Theory] - [InlineData(2.0, 1.2, 4.2, 0.6)] + [InlineData(2.0, 5.2, 4.2, 0.6)] public void TestTaskA(double a, double xn, double xk, double dx) { - var resultA = Program.TaskA(a, xn, xk, dx); - Assert.Equal(resultA, new double[0]); + var res = Program.TaskA(a, xn, xk, dx); + Assert.Equal(res, new double[5]); } [Theory] [InlineData(2.0, 1.2, 4.2, 0.6)] @@ -21,21 +21,22 @@ public void Test(double a, double xn, double xk, double dx) var result = new int[resultA.Length]; foreach (var item in resultA) { - result[k] = (int)Math.Floor(resA[k]); + result[k] = (int)Math.Floor(resultA[k]*1000); k++; } var exp = new int[] {24, 23, 21, 19, 17}; - Assert.Equal(result, exp, 3); + Assert.Equal(result, exp); } - [Theory] - public void TestTaskB() + [Theory] + [InlineData(2.0)] + public void TestTaskB(double a) { var mass = new double[] { 1.16, 1.32, 1.47, 1.65, 1.93 }; - var resultB = Program.TaskB(2.0, mass); - var expy = new double[] { 0.0250047248573638, 0.0246393618709823, 0.0242470198513219, 0.0237322773817727, 0.0228750269630625} + var resultB = Program.TaskB(a, mass); + var expy = new double[] { 0.0250047248573638, 0.0246393618709823, 0.0242470198513219, 0.0237322773817727, 0.0228750269630625}; for (int i = 0; i < 5; i++) { - Assert.Equal(expy[i], resultB[i], 3); + Assert.Equal(expy[i], resultB[i], 3 ); } } } diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index fbe0237..39bc8f4 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -8,45 +8,42 @@ public static double[] TaskA(double a, double xn, double xk, double dx) { int k = 0; var y = new double[5]; - for (var i = xn; i < xk; i += dx) - { - y[k] = Math.Pow(Math.Log10(a + i), 2) / Math.Pow(a + i, 2); - k++; - } + for (var i = xn; i < xk; i += dx) + { + y[k] = Math.Pow(Math.Log10(a + i), 2) / Math.Pow(a + i, 2); + k++; + } return y; } - public static double[] TaskB(double a, double[] x) { var y = new double[x.Length]; for (var i = 0; i < y.Length; i++) - { - y[i] = Math.Pow(Math.Log10(a + x[i]), 2) / Math.Pow(a + x[i], 2); - } + { + y[i] = Math.Pow(Math.Log10(a + x[i]), 2) / Math.Pow(a + x[i], 2); + } return y; } - public static void Main(string[] args) { double a = 2.0; double xn = 1.2; double xk = 4.2; double dx = 0.6; - - var resSingle = TaskA(a, xn, xk, dx); + var resA = TaskA(a, xn, xk, dx); Console.WriteLine("Задание А:"); - foreach (var item in resSingle) - { - Console.WriteLine($"y = {item}"); - } - + foreach (var item in resA) + { + Console.WriteLine($"y = {item}"); + } + var x = new double[] { 1.16, 1.32, 1.47, 1.65, 1.93 }; var taskBRes = TaskB(a, x); Console.WriteLine("Задание В:"); foreach (var item in taskBRes) - { - Console.WriteLine($"y1 = {item}"); - } + { + Console.WriteLine($"y1 = {item}"); + } Console.ReadLine(); } } From 1faf0dc1fa3fc33932ab7d21bbdbb53db09da031 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Thu, 14 Nov 2019 15:07:36 +0300 Subject: [PATCH 10/41] lav1.2 --- CourseApp.Tests/DemoTest.cs | 27 -------------- CourseApp.Tests/PlatypusTest.cs | 55 ---------------------------- CourseApp/CourseApp.sln | 31 ---------------- CourseApp/Platypus.cs | 60 ------------------------------- CourseApp/Program.cs | 63 --------------------------------- 5 files changed, 236 deletions(-) delete mode 100644 CourseApp.Tests/PlatypusTest.cs delete mode 100644 CourseApp/CourseApp.sln delete mode 100644 CourseApp/Platypus.cs diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs index bb4cf09..f40a002 100644 --- a/CourseApp.Tests/DemoTest.cs +++ b/CourseApp.Tests/DemoTest.cs @@ -6,38 +6,11 @@ namespace CourseApp.Tests public class DemoTest { [Theory] - [InlineData(2.0, 5.2, 4.2, 0.6)] public void TestTaskA(double a, double xn, double xk, double dx) { var res = Program.TaskA(a, xn, xk, dx); Assert.Equal(res, new double[5]); - - [InlineData(0, 0, 0, double.NaN)] - [InlineData(1, 1, 2, 2.5)] - [InlineData(-1, 1, 1, 0)] - public void TestCalc(double a, double b, double x, double exp) - { - var res = Program.MyFunction(a, b, x); - Assert.Equal(exp, res, 3); - } - - [Fact] - public void TestNormalA() - { - } - - [Fact] - public void TestNormalB() - { - } - - [Fact] - public void TestZeroLengthB() - { - var res = Program.TaskB(1, 1, new double[0]); - Assert.Empty(res); - } [Theory] [InlineData(2.0, 1.2, 4.2, 0.6)] diff --git a/CourseApp.Tests/PlatypusTest.cs b/CourseApp.Tests/PlatypusTest.cs deleted file mode 100644 index 77c4d8f..0000000 --- a/CourseApp.Tests/PlatypusTest.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using Xunit; - -namespace CourseApp.Tests -{ - public class PlatypusTest - { - [Fact] - public void TestEmptyConstructor() - { - var item = new Platypus(); - Assert.Equal(0, item.Age); - Assert.Equal("Untitled", item.Name); - Assert.True(item.IsMale); - } - - [Fact] - public void TestView() - { - var item = new Platypus(); - var view = @" - _.-^~~^^^`~-,_,,~''''''```~,''``~'``~, - ______,' -o :. _ . ; ,'`, `. -( -\.._,.;;'._ ,( } _`_-_,, `, `, - ``~~~~~~' ((/'((((____/~~~~~~'(,(,___> `~' - "; - Assert.Equal(view, item.View()); - } - - [Fact] - public void TestSetAge() - { - var item = new Platypus(); - item.Age = 5; - Assert.Equal(5, item.Age); - } - - [Fact] - public void TestIncorrectSetAge() - { - var item = new Platypus(); - item.Age = -5; - Assert.Equal(0, item.Age); - } - - [Fact] - public void TestCorrectIncorrectSetAge() - { - var item = new Platypus(); - item.Age = 10; - item.Age = -5; - Assert.Equal(10, item.Age); - } - } -} diff --git a/CourseApp/CourseApp.sln b/CourseApp/CourseApp.sln deleted file mode 100644 index 3dac3f4..0000000 --- a/CourseApp/CourseApp.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.852 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp", "CourseApp.csproj", "{17CB0273-34D3-4D23-965F-FC4AD0A83D0F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "..\CourseApp.Tests\CourseApp.Tests.csproj", "{E0133767-62A2-4B4A-87A2-BD09BC775E0A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {17CB0273-34D3-4D23-965F-FC4AD0A83D0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {17CB0273-34D3-4D23-965F-FC4AD0A83D0F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {17CB0273-34D3-4D23-965F-FC4AD0A83D0F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {17CB0273-34D3-4D23-965F-FC4AD0A83D0F}.Release|Any CPU.Build.0 = Release|Any CPU - {E0133767-62A2-4B4A-87A2-BD09BC775E0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E0133767-62A2-4B4A-87A2-BD09BC775E0A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E0133767-62A2-4B4A-87A2-BD09BC775E0A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E0133767-62A2-4B4A-87A2-BD09BC775E0A}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1849B280-B447-4D18-9764-F412B7768C4F} - EndGlobalSection -EndGlobal diff --git a/CourseApp/Platypus.cs b/CourseApp/Platypus.cs deleted file mode 100644 index eb3d463..0000000 --- a/CourseApp/Platypus.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; - -namespace CourseApp -{ - public class Platypus - { - private int age; - - public Platypus() - : this(0, "Untitled", true) - { - } - - public Platypus(int age, string name, bool isMale) - { - Name = name; - Age = age; - IsMale = isMale; - } - - public string Name { get; set; } - - public int Age - { - get - { - return this.age; - } - - set - { - if (value >= 0 && value < 20) - { - this.age = value; - } - else - { - Console.WriteLine("Age should be > 0 and < than 20"); - } - } - } - - public bool IsMale { get; set; } - - public bool IsPoisoned - { - get { return this.IsMale; } - } - - public string View() - { - return @" - _.-^~~^^^`~-,_,,~''''''```~,''``~'``~, - ______,' -o :. _ . ; ,'`, `. -( -\.._,.;;'._ ,( } _`_-_,, `, `, - ``~~~~~~' ((/'((((____/~~~~~~'(,(,___> `~' - "; - } - } -} \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index a44f5e5..39bc8f4 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -4,7 +4,6 @@ namespace CourseApp { public class Program { - public static double[] TaskA(double a, double xn, double xk, double dx) { int k = 0; @@ -45,68 +44,6 @@ public static void Main(string[] args) { Console.WriteLine($"y1 = {item}"); } - - public static double MyFunction(double a, double b, double x) - { - var c = (b * x) + (a / x); - return c; - } - - public static double[] TaskA ( - double a, - double b, - double xn, - double xk, - double dx) - { - var steps = (int)Math.Floor((xk - xn) / dx); - var y = new double[steps]; - var i = 0; - for (var x = xn; x < xk; x += dx) - { - y[i] = MyFunction(a, b, x); - i++; - } - - return y; - } - - public static double[] TaskB ( - double a, - double b, - double[] x) - { - var y = new double[x.Length]; - for (int i = 0; i < x.Length; i++) - { - y[i] = MyFunction(a, b, x[i]); - } - - return y; - } - - public static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - var taskA = TaskA(2, 3, 0, 5, 1); - Console.WriteLine(taskA); - - for (var i = 0; i < taskA.Length; i++) - { - Console.WriteLine($"y={taskA[i]}"); - } - - var xB = new double[] { 0, 1, 2, 3 }; - var taskB = TaskB(2, 3, xB); - for (var i = 0; i < xB.Length; i++) - { - Console.WriteLine($"x={xB[i]} y={taskB[i]}"); - } - - var item = new Platypus(); - Console.WriteLine(item.View()); - - Console.ReadLine(); } } From a623cd7eed552799ce2d6b3c5193127b204014d9 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Thu, 14 Nov 2019 15:12:29 +0300 Subject: [PATCH 11/41] lab1.3 --- CourseApp/CourseApp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index dffae8d..127fa8f 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -3,7 +3,7 @@ Exe netcoreapp2.0 - True + False 1573,1591,1701;1702;1705; From 9df31ec1497bfa1118641649cd60d654d46ce8b3 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Thu, 14 Nov 2019 16:09:28 +0300 Subject: [PATCH 12/41] lab1.3 --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 4c873c5..d9dc46d 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -3,7 +3,7 @@ netcoreapp2.1 1573,1591,1701;1702;1705 - false + True From d54fe385f18295307877923985c9593e620ac680 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Fri, 22 Nov 2019 23:55:33 +0300 Subject: [PATCH 13/41] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D1=8B+=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 205 ------------------------- CourseApp.Tests/CourseApp.Tests.csproj | 4 +- CourseApp.Tests/DogTest.cs | 53 +++++++ CourseApp/CourseApp.csproj | 2 +- CourseApp/Dog.cs | 52 +++++++ CourseApp/Program.cs | 12 +- 6 files changed, 119 insertions(+), 209 deletions(-) delete mode 100644 .gitignore create mode 100644 CourseApp.Tests/DogTest.cs create mode 100644 CourseApp/Dog.cs diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 24cb440..0000000 --- a/.gitignore +++ /dev/null @@ -1,205 +0,0 @@ -# Download this file using PowerShell v3 under Windows with the following comand: -# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore -# or wget: -# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc - -# OS generated files # -.DS_Store* -Icon? - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -*.Cache -ClientBin/ -# [Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings -modulesbin/ -tempbin/ - -# EPiServer Site file (VPP) -AppData/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# vim -*.txt~ -*.swp -*.swo - -# svn -.svn - -# Remainings from resolvings conflicts in Source Control -*.orig - -# SQL Server files -**/App_Data/*.mdf -**/App_Data/*.ldf -**/App_Data/*.sdf - - -#LightSwitch generated files -GeneratedArtifacts/ -_Pvt_Extensions/ -ModelManifest.xml - -# ========================= -# Windows detritus -# ========================= - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac desktop service store files -.DS_Store - -# SASS Compiler cache -.sass-cache - -# Visual Studio 2014 CTP -**/*.sln.ide - -# Visual Studio temp something -.vs/ - -# VS 2015+ -*.vc.vc.opendb -*.vc.db - -# Rider -.idea/ - -**/node_modules/* - -# Added by Jskonst -Properties/ - -##### -# End of core ignore list, below put you custom 'per project' settings (patterns or path) -##### \ No newline at end of file diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index d9dc46d..8c2b174 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -1,9 +1,9 @@ - netcoreapp2.1 + netcoreapp3.0 1573,1591,1701;1702;1705 - True + false diff --git a/CourseApp.Tests/DogTest.cs b/CourseApp.Tests/DogTest.cs new file mode 100644 index 0000000..75196fd --- /dev/null +++ b/CourseApp.Tests/DogTest.cs @@ -0,0 +1,53 @@ +using System; +using Xunit; +using CourseApp; + +namespace CourseApp.Tests +{ + public class UnitTest2 + { + [Fact] + public void Test4() + { + Dog snech = new Dog(); + + Assert.Equal(15, snech.Age); + Assert.Equal(50.0f, snech.Weight); + Assert.Equal("K", snech.Pol); + } + + [Fact] + public void Test5() + { + Dog snech = new Dog("S"); + Assert.Equal(12, snech.Age); + Assert.Equal(45.0f, snech.Weight); + } + + [Fact] + public void Test6() + { + Dog snech = new Dog("K"); + Assert.Equal(14, snech.Age); + Assert.Equal(50.0f, snech.Weight); + } + + [Fact] + public void Test7() + { + Dog snech = new Dog(); + Assert.Equal( + @" __ _ +o'')}____// + `_/ ) + (_(_/-(_/", snech.GetPicture()); + } + + [Fact] + public void Test8() + { + Dog snech = new Dog(); + Assert.Equal($"собака возраста {15} подала голос гав-гав ", snech.GetVoice()); + } + } +} \ No newline at end of file diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index 127fa8f..124dd30 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.0 + netcoreapp3.0 False 1573,1591,1701;1702;1705; diff --git a/CourseApp/Dog.cs b/CourseApp/Dog.cs new file mode 100644 index 0000000..826d941 --- /dev/null +++ b/CourseApp/Dog.cs @@ -0,0 +1,52 @@ +using System; + +namespace CourseApp +{ + public class Dog + { + public Dog() + { + Pol = "K"; + Age = 15; + Weight = 50.0f; + } + + public Dog(string n) + { + Pol = n; + if (Pol == "S") + { + Age = 12; + Weight = 45.0f; + } + else + { + Age = 14; + Weight = 50.0f; + } + } + public float Weight { get; set; } + + public int Age { get; set; } + + public string Pol { get; set; } + + public void GetInfo() + { + Console.WriteLine($"Пол: {Pol} Возраст: {Age} Вес: {Weight}"); + } + + public string GetVoice() + { + return $"собака возраста {Age} подала голос гав-гав "; + } + + public string GetPicture() + { + return @" __ _ +o'')}____// + `_/ ) + (_(_/-(_/"; + } + } +} \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 39bc8f4..0d53837 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -31,19 +31,29 @@ public static void Main(string[] args) double xk = 4.2; double dx = 0.6; var resA = TaskA(a, xn, xk, dx); + Console.WriteLine("=========="); Console.WriteLine("Задание А:"); + Console.WriteLine("=========="); foreach (var item in resA) { Console.WriteLine($"y = {item}"); } - + Console.WriteLine("=========="); var x = new double[] { 1.16, 1.32, 1.47, 1.65, 1.93 }; var taskBRes = TaskB(a, x); Console.WriteLine("Задание В:"); + Console.WriteLine("=========="); foreach (var item in taskBRes) { Console.WriteLine($"y1 = {item}"); } + Console.WriteLine("=========="); + Console.WriteLine("My first class in C#"); + + Dog snech = new Dog(); + snech.GetInfo(); + Console.WriteLine(snech.GetVoice()); + Console.WriteLine(snech.GetPicture()); Console.ReadLine(); } } From 70ea92ae6d67dcf461199ab911c35e9425aa83da Mon Sep 17 00:00:00 2001 From: DeC0re Date: Fri, 22 Nov 2019 23:59:08 +0300 Subject: [PATCH 14/41] Fix error --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- CourseApp/CourseApp.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 8c2b174..a8e0953 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netcoreapp2.0 1573,1591,1701;1702;1705 false diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index 124dd30..127fa8f 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + netcoreapp2.0 False 1573,1591,1701;1702;1705; From 270ac224366f894255bf3a5acf985b10e2ccec9b Mon Sep 17 00:00:00 2001 From: DeC0re Date: Sat, 23 Nov 2019 00:00:46 +0300 Subject: [PATCH 15/41] Fix error 1.2 --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- CourseApp/CourseApp.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index a8e0953..5fa74f9 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -3,7 +3,7 @@ netcoreapp2.0 1573,1591,1701;1702;1705 - false + true diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index 127fa8f..f4d3e7f 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -3,7 +3,7 @@ Exe netcoreapp2.0 - False + true 1573,1591,1701;1702;1705; From 78512a33df920b6cf70f22f7501f489169d3cef5 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Sat, 23 Nov 2019 00:05:46 +0300 Subject: [PATCH 16/41] Fix error 1.3 --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- CourseApp/CourseApp.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 5fa74f9..a8e0953 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -3,7 +3,7 @@ netcoreapp2.0 1573,1591,1701;1702;1705 - true + false diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index f4d3e7f..7622773 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -3,7 +3,7 @@ Exe netcoreapp2.0 - true + false 1573,1591,1701;1702;1705; From 1dcfc75318417328185694779a1dd42d4fd77b25 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Mon, 9 Dec 2019 15:53:37 +0300 Subject: [PATCH 17/41] Full --- .github/workflows/dotnetcore.yml | 2 +- .gitignore | 205 +++++++++++++++++++++++++ CourseApp.Tests/CourseApp.Tests.csproj | 18 ++- CourseApp.Tests/DemoTest.cs | 38 +++-- CourseApp.Tests/DogTest.cs | 64 ++++---- CourseApp/CourseApp.csproj | 6 +- CourseApp/Dog.cs | 75 +++++---- CourseApp/Program.cs | 30 ++-- 8 files changed, 344 insertions(+), 94 deletions(-) create mode 100644 .gitignore diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 22cc4eb..502e5ce 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 2.1.802 + dotnet-version: 3.0.100 - name: Build with dotnet run: | cd CourseApp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..24cb440 --- /dev/null +++ b/.gitignore @@ -0,0 +1,205 @@ +# Download this file using PowerShell v3 under Windows with the following comand: +# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore +# or wget: +# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# OS generated files # +.DS_Store* +Icon? + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +*.Cache +ClientBin/ +# [Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings +modulesbin/ +tempbin/ + +# EPiServer Site file (VPP) +AppData/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# vim +*.txt~ +*.swp +*.swo + +# svn +.svn + +# Remainings from resolvings conflicts in Source Control +*.orig + +# SQL Server files +**/App_Data/*.mdf +**/App_Data/*.ldf +**/App_Data/*.sdf + + +#LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +# SASS Compiler cache +.sass-cache + +# Visual Studio 2014 CTP +**/*.sln.ide + +# Visual Studio temp something +.vs/ + +# VS 2015+ +*.vc.vc.opendb +*.vc.db + +# Rider +.idea/ + +**/node_modules/* + +# Added by Jskonst +Properties/ + +##### +# End of core ignore list, below put you custom 'per project' settings (patterns or path) +##### \ No newline at end of file diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index a8e0953..21e7368 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -1,20 +1,30 @@ - netcoreapp2.0 + netcoreapp3.0 + True 1573,1591,1701;1702;1705 false - + - + - + + ../_stylecop/stylecop.ruleset + true + + + + + + + \ No newline at end of file diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs index f40a002..548d4db 100644 --- a/CourseApp.Tests/DemoTest.cs +++ b/CourseApp.Tests/DemoTest.cs @@ -1,39 +1,45 @@ using System; using Xunit; +using System.Collections.Generic; namespace CourseApp.Tests { public class DemoTest { + [Theory] + [InlineData(2, 4, 0.01682)] + [InlineData(10, -5, 0.0195424)] + public void TestMyFunction(double a, double x, double exp) + { + Assert.Equal(Program.Function(a, x), exp, 3); + } + [Theory] [InlineData(2.0, 5.2, 4.2, 0.6)] + public void TestTaskA(double a, double xn, double xk, double dx) { var res = Program.TaskA(a, xn, xk, dx); - Assert.Equal(res, new double[5]); + Assert.Equal(res, new List(5)); } - [Theory] - [InlineData(2.0, 1.2, 4.2, 0.6)] - public void Test(double a, double xn, double xk, double dx) + [Fact] + public void Test1() { - int k = 0; - var resultA = Program.TaskA(a, xn, xk, dx); - var result = new int[resultA.Length]; - foreach (var item in resultA) - { - result[k] = (int)Math.Floor(resultA[k]*1000); - k++; - } - var exp = new int[] {24, 23, 21, 19, 17}; - Assert.Equal(result, exp); + Xunit.Assert.True(true); + } + [Fact] + public void TestZeroFunction() + { + var res = Program.Function(0.0, 0.0); + Xunit.Assert.Equal(double.PositiveInfinity, res); } [Theory] [InlineData(2.0)] public void TestTaskB(double a) { - var mass = new double[] { 1.16, 1.32, 1.47, 1.65, 1.93 }; + var mass = new List { 1.16, 1.32, 1.47, 1.65, 1.93 }; var resultB = Program.TaskB(a, mass); - var expy = new double[] { 0.0250047248573638, 0.0246393618709823, 0.0242470198513219, 0.0237322773817727, 0.0228750269630625}; + var expy = new List { 0.0250047248573638, 0.0246393618709823, 0.0242470198513219, 0.0237322773817727, 0.0228750269630625}; for (int i = 0; i < 5; i++) { Assert.Equal(expy[i], resultB[i], 3 ); diff --git a/CourseApp.Tests/DogTest.cs b/CourseApp.Tests/DogTest.cs index 75196fd..68cb05e 100644 --- a/CourseApp.Tests/DogTest.cs +++ b/CourseApp.Tests/DogTest.cs @@ -1,53 +1,63 @@ using System; using Xunit; -using CourseApp; namespace CourseApp.Tests { - public class UnitTest2 + public class DogTest { [Fact] - public void Test4() + public void TestConstructor() { - Dog snech = new Dog(); - - Assert.Equal(15, snech.Age); - Assert.Equal(50.0f, snech.Weight); - Assert.Equal("K", snech.Pol); + var item = new Dog(); + Assert.Equal(1, item.Age); + Assert.Equal("Test", item.Name); + Assert.Equal("male", item.Sex); } [Fact] - public void Test5() + public void TestSetAge() { - Dog snech = new Dog("S"); - Assert.Equal(12, snech.Age); - Assert.Equal(45.0f, snech.Weight); + var item = new Dog(); + item.Age = 3; + Assert.Equal(3, item.Age); } [Fact] - public void Test6() + public void TestWrongAge() { - Dog snech = new Dog("K"); - Assert.Equal(14, snech.Age); - Assert.Equal(50.0f, snech.Weight); + var item = new Dog(); + try + { + item.Age = 0; + } + catch (System.Exception) + { + Console.WriteLine("ERROR! Rewrite Age!"); + Assert.True(true); + } } [Fact] - public void Test7() + public void TestWrongSex() { - Dog snech = new Dog(); - Assert.Equal( - @" __ _ -o'')}____// - `_/ ) - (_(_/-(_/", snech.GetPicture()); + var item = new Dog(); + try + { + item.Sex = "lemonade"; + } + catch (System.Exception) + { + Console.WriteLine("ERROR! Rewrite Sex!"); + Assert.True(true); + } } - [Fact] - public void Test8() + public void FullTest() { - Dog snech = new Dog(); - Assert.Equal($"собака возраста {15} подала голос гав-гав ", snech.GetVoice()); + var item = new Dog("Doberman", 3, "male"); + Assert.Equal("Doberman", item.Name); + Assert.Equal("male", item.Sex); + Assert.Equal(3, item.Age); } } } \ No newline at end of file diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index 7622773..c941549 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,8 +2,8 @@ Exe - netcoreapp2.0 - false + netcoreapp3.0 + True 1573,1591,1701;1702;1705; @@ -20,4 +20,4 @@ - + \ No newline at end of file diff --git a/CourseApp/Dog.cs b/CourseApp/Dog.cs index 826d941..b8f1165 100644 --- a/CourseApp/Dog.cs +++ b/CourseApp/Dog.cs @@ -1,52 +1,71 @@ using System; +using System.Collections.Generic; namespace CourseApp { public class Dog { + private int age; + private string sex; + public string Name { get; set; } public Dog() + : this("Test") { - Pol = "K"; - Age = 15; - Weight = 50.0f; } - - public Dog(string n) + public string Sex { - Pol = n; - if (Pol == "S") + get { - Age = 12; - Weight = 45.0f; + return this.sex; } - else + set { - Age = 14; - Weight = 50.0f; + if (value == "male") + { + this.sex = value; + } + else + { + throw new System.Exception(); + } } } - public float Weight { get; set; } - - public int Age { get; set; } - - public string Pol { get; set; } - - public void GetInfo() + public Dog(string name, int age, string sex) { - Console.WriteLine($"Пол: {Pol} Возраст: {Age} Вес: {Weight}"); + Name = name; + Age = age; + Sex = sex; } - - public string GetVoice() + public Dog(string name) + : this(name, 1, "male") { - return $"собака возраста {Age} подала голос гав-гав "; } + public int Age + { + get + { + return this.age; + } - public string GetPicture() + set + { + if (value >= 1 && value < 10) + { + this.age = value; + } + else + { + throw new System.Exception(); + } + } + } + public override string ToString() + { + return $"Имя:{Name},Возраст:{Age},Пол:{Sex}"; + } + public void AgeUp() { - return @" __ _ -o'')}____// - `_/ ) - (_(_/-(_/"; + this.age++; } } } \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 0d53837..902268a 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,26 +1,33 @@ using System; +using System.Collections.Generic; namespace CourseApp { public class Program { - public static double[] TaskA(double a, double xn, double xk, double dx) + public static double Function(double a, double x) + { + var y = (Math.Pow(Math.Log10(a + x), 2) / (Math.Pow(a + x, 2))); + return y; + } + public static List TaskA(double a, double xn, double xk, double dx) { int k = 0; - var y = new double[5]; + List y = new List(5); for (var i = xn; i < xk; i += dx) { - y[k] = Math.Pow(Math.Log10(a + i), 2) / Math.Pow(a + i, 2); + y.Add(Math.Pow(Math.Log10(a + i), 2) / (Math.Pow(a + i, 2))); k++; } return y; + } - public static double[] TaskB(double a, double[] x) + public static List TaskB(double a, List x) { - var y = new double[x.Length]; - for (var i = 0; i < y.Length; i++) + List y = new List(5); + for (var i = 0; i < x.Count; i++) { - y[i] = Math.Pow(Math.Log10(a + x[i]), 2) / Math.Pow(a + x[i], 2); + y.Add(Math.Pow(Math.Log10(a + x[i]), 2) / Math.Pow(a + x[i], 2)); } return y; } @@ -39,7 +46,7 @@ public static void Main(string[] args) Console.WriteLine($"y = {item}"); } Console.WriteLine("=========="); - var x = new double[] { 1.16, 1.32, 1.47, 1.65, 1.93 }; + List x = new List { 1.16, 1.32, 1.47, 1.65, 1.93 }; var taskBRes = TaskB(a, x); Console.WriteLine("Задание В:"); Console.WriteLine("=========="); @@ -48,13 +55,6 @@ public static void Main(string[] args) Console.WriteLine($"y1 = {item}"); } Console.WriteLine("=========="); - Console.WriteLine("My first class in C#"); - - Dog snech = new Dog(); - snech.GetInfo(); - Console.WriteLine(snech.GetVoice()); - Console.WriteLine(snech.GetPicture()); - Console.ReadLine(); } } } From cfec148f975462db7c08331f941df71c6b15d62e Mon Sep 17 00:00:00 2001 From: DeC0re Date: Mon, 9 Dec 2019 16:03:41 +0300 Subject: [PATCH 18/41] fix error --- .github/workflows/dotnetcore.yml | 2 +- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- CourseApp/CourseApp.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 502e5ce..22cc4eb 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.0.100 + dotnet-version: 2.1.802 - name: Build with dotnet run: | cd CourseApp diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 21e7368..53cfe73 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netcoreapp2.1 True 1573,1591,1701;1702;1705 false diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index c941549..a702dd8 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + netcoreapp2.1 True 1573,1591,1701;1702;1705; From 23d768b509e76e4d23e9284399ff99937d3fd46e Mon Sep 17 00:00:00 2001 From: DeC0re Date: Mon, 9 Dec 2019 16:42:39 +0300 Subject: [PATCH 19/41] Full lab v2 --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- CourseApp/CourseApp.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 53cfe73..d0d9067 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -2,7 +2,7 @@ netcoreapp2.1 - True + False 1573,1591,1701;1702;1705 false diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index a702dd8..99656c7 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -3,7 +3,7 @@ Exe netcoreapp2.1 - True + False 1573,1591,1701;1702;1705; From 5fcb268dcc96787136e813bdbfb8427610bba764 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Mon, 16 Dec 2019 12:38:15 +0300 Subject: [PATCH 20/41] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- CourseApp.Tests/DemoTest.cs | 43 ++++++++++++++++---------- CourseApp.Tests/DogTest.cs | 1 + CourseApp/CourseApp.csproj | 2 +- CourseApp/Dog.cs | 33 +++++++++++++------- CourseApp/Program.cs | 23 +++++++++----- 6 files changed, 65 insertions(+), 39 deletions(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index d0d9067..53cfe73 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -2,7 +2,7 @@ netcoreapp2.1 - False + True 1573,1591,1701;1702;1705 false diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs index 548d4db..11a7808 100644 --- a/CourseApp.Tests/DemoTest.cs +++ b/CourseApp.Tests/DemoTest.cs @@ -1,6 +1,6 @@ using System; -using Xunit; using System.Collections.Generic; +using Xunit; namespace CourseApp.Tests { @@ -14,36 +14,45 @@ public void TestMyFunction(double a, double x, double exp) Assert.Equal(Program.Function(a, x), exp, 3); } - [Theory] - [InlineData(2.0, 5.2, 4.2, 0.6)] - - public void TestTaskA(double a, double xn, double xk, double dx) + [Fact] + + public void TestTaskA() { - var res = Program.TaskA(a, xn, xk, dx); - Assert.Equal(res, new List(5)); + double a = 2.0; + double xn = 1.2; + double xk = 4.2; + double dx = 0.6; + List res = Program.TaskA(a, xn, xk, dx); + List expy = new List { 0.024919580136386867, 0.02327901792977313, 0.02138591667754329, 0.019542362678459768, 0.01785029731362981 }; + for (int i = 0; i < 5; i++) + { + Assert.Equal(expy[i], res[i], 3); + } } + [Fact] public void Test1() { - Xunit.Assert.True(true); + Assert.True(true); } + [Fact] public void TestZeroFunction() { var res = Program.Function(0.0, 0.0); - Xunit.Assert.Equal(double.PositiveInfinity, res); + Assert.Equal(double.PositiveInfinity, res); } - [Theory] - [InlineData(2.0)] - public void TestTaskB(double a) + + [Fact] + public void TestTaskB() { - var mass = new List { 1.16, 1.32, 1.47, 1.65, 1.93 }; - var resultB = Program.TaskB(a, mass); - var expy = new List { 0.0250047248573638, 0.0246393618709823, 0.0242470198513219, 0.0237322773817727, 0.0228750269630625}; + List x = new List { 1.16, 1.32, 1.47, 1.65, 1.93 }; + List res = Program.TaskB(2.0, x); + List expy = new List { 0.025004724857363752, 0.024639361870982292, 0.024247019851321865, 0.023732277381772752, 0.022875026963062515 }; for (int i = 0; i < 5; i++) { - Assert.Equal(expy[i], resultB[i], 3 ); + Assert.Equal(expy[i], res[i], 3); } - } + } } } diff --git a/CourseApp.Tests/DogTest.cs b/CourseApp.Tests/DogTest.cs index 68cb05e..2a7e724 100644 --- a/CourseApp.Tests/DogTest.cs +++ b/CourseApp.Tests/DogTest.cs @@ -51,6 +51,7 @@ public void TestWrongSex() Assert.True(true); } } + [Fact] public void FullTest() { diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index 99656c7..a702dd8 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -3,7 +3,7 @@ Exe netcoreapp2.1 - False + True 1573,1591,1701;1702;1705; diff --git a/CourseApp/Dog.cs b/CourseApp/Dog.cs index b8f1165..28e3596 100644 --- a/CourseApp/Dog.cs +++ b/CourseApp/Dog.cs @@ -7,17 +7,33 @@ public class Dog { private int age; private string sex; - public string Name { get; set; } + public Dog() : this("Test") { } + + public Dog(string name, int age, string sex) + { + Name = name; + Age = age; + Sex = sex; + } + + public Dog(string name) + : this(name, 1, "male") + { + } + + public string Name { get; set; } + public string Sex { get { return this.sex; } + set { if (value == "male") @@ -30,16 +46,7 @@ public string Sex } } } - public Dog(string name, int age, string sex) - { - Name = name; - Age = age; - Sex = sex; - } - public Dog(string name) - : this(name, 1, "male") - { - } + public int Age { get @@ -59,10 +66,12 @@ public int Age } } } - public override string ToString() + + public override string ToString() { return $"Имя:{Name},Возраст:{Age},Пол:{Sex}"; } + public void AgeUp() { this.age++; diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 902268a..796cc4d 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -7,30 +7,35 @@ public class Program { public static double Function(double a, double x) { - var y = (Math.Pow(Math.Log10(a + x), 2) / (Math.Pow(a + x, 2))); + var y = Math.Pow(Math.Log10(a + x), 2) / Math.Pow(a + x, 2); + return y; } + public static List TaskA(double a, double xn, double xk, double dx) { int k = 0; - List y = new List(5); - for (var i = xn; i < xk; i += dx) + List y = new List(5); + for (var i = xn; i < xk; i += dx) { - y.Add(Math.Pow(Math.Log10(a + i), 2) / (Math.Pow(a + i, 2))); + y.Add(Function(a, i)); k++; } + return y; - } + public static List TaskB(double a, List x) { - List y = new List(5); + List y = new List(5); for (var i = 0; i < x.Count; i++) { - y.Add(Math.Pow(Math.Log10(a + x[i]), 2) / Math.Pow(a + x[i], 2)); + y.Add(Function(a, x[i])); } + return y; } + public static void Main(string[] args) { double a = 2.0; @@ -45,7 +50,8 @@ public static void Main(string[] args) { Console.WriteLine($"y = {item}"); } - Console.WriteLine("=========="); + + Console.WriteLine("=========="); List x = new List { 1.16, 1.32, 1.47, 1.65, 1.93 }; var taskBRes = TaskB(a, x); Console.WriteLine("Задание В:"); @@ -54,6 +60,7 @@ public static void Main(string[] args) { Console.WriteLine($"y1 = {item}"); } + Console.WriteLine("=========="); } } From 7aafca5f1f446dcd01978ed3b5f6d3a9e9e3fbfd Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Mon, 16 Dec 2019 22:34:59 +0300 Subject: [PATCH 21/41] Update Dog.cs --- CourseApp/Dog.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CourseApp/Dog.cs b/CourseApp/Dog.cs index 28e3596..210a713 100644 --- a/CourseApp/Dog.cs +++ b/CourseApp/Dog.cs @@ -74,7 +74,7 @@ public override string ToString() public void AgeUp() { - this.age++; + this.Age++; } } -} \ No newline at end of file +} From f6764223c55431cb429a6534f385e52b4c2b8819 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Wed, 18 Dec 2019 00:19:49 +0300 Subject: [PATCH 22/41] Age --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- CourseApp/AgeClass.cs | 43 ++++++++++++++++++++++++++ CourseApp/CourseApp.csproj | 2 +- CourseApp/Program.cs | 1 + 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 CourseApp/AgeClass.cs diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 53cfe73..21e7368 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + netcoreapp3.0 True 1573,1591,1701;1702;1705 false diff --git a/CourseApp/AgeClass.cs b/CourseApp/AgeClass.cs new file mode 100644 index 0000000..e094e5d --- /dev/null +++ b/CourseApp/AgeClass.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; + +namespace CourseApp +{ + public class AgeClass + { + public static string Age() + { + Console.WriteLine("Введите год своего рождения:"); + int years = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Введите месяц своего рождения:"); + int months = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Введите день своего рождения:"); + int days = Convert.ToInt32(Console.ReadLine()); + DateTime result = DateCompare(new DateTime(years, months, days), DateTime.Now); + return $"Вам {result.Year - 1} лет, {result.Month - 1} месяцев и {result.Day - 1} дня"; + } + + public static string Age(int days, int months, int years) + { + DateTime result = DateCompare(new DateTime(years, months, days), DateTime.Now); + return $"Вам {result.Day - 1} дня, {result.Month - 1} месяцев и {result.Year - 1} лет"; + } + + public static DateTime DateCompare(DateTime date1, DateTime date2) + { + if (date1.Ticks < date2.Ticks) + { + DateTime res = new DateTime(date2.Ticks - date1.Ticks); + return res; + } + + throw new Exception(); + } + + public static string Age(DateTime date) + { + var dateCompar = DateCompare(date, DateTime.Now); + return $"Вам {dateCompar.Day - 1} дня, {dateCompar.Month - 1} месяцев и {dateCompar.Year - 1} лет"; + } + } +} \ No newline at end of file diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index a702dd8..c941549 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.1 + netcoreapp3.0 True 1573,1591,1701;1702;1705; diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 796cc4d..b66e0ee 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -62,6 +62,7 @@ public static void Main(string[] args) } Console.WriteLine("=========="); + Console.WriteLine(AgeClass.Age()); } } } From 665629c841b7ff504242fe1a4e95f33ae5a8c9de Mon Sep 17 00:00:00 2001 From: DeC0re Date: Wed, 18 Dec 2019 23:27:46 +0300 Subject: [PATCH 23/41] test --- CourseApp/AgeClass.cs | 43 ------------------------------------------- CourseApp/Program.cs | 1 - 2 files changed, 44 deletions(-) delete mode 100644 CourseApp/AgeClass.cs diff --git a/CourseApp/AgeClass.cs b/CourseApp/AgeClass.cs deleted file mode 100644 index e094e5d..0000000 --- a/CourseApp/AgeClass.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace CourseApp -{ - public class AgeClass - { - public static string Age() - { - Console.WriteLine("Введите год своего рождения:"); - int years = Convert.ToInt32(Console.ReadLine()); - Console.WriteLine("Введите месяц своего рождения:"); - int months = Convert.ToInt32(Console.ReadLine()); - Console.WriteLine("Введите день своего рождения:"); - int days = Convert.ToInt32(Console.ReadLine()); - DateTime result = DateCompare(new DateTime(years, months, days), DateTime.Now); - return $"Вам {result.Year - 1} лет, {result.Month - 1} месяцев и {result.Day - 1} дня"; - } - - public static string Age(int days, int months, int years) - { - DateTime result = DateCompare(new DateTime(years, months, days), DateTime.Now); - return $"Вам {result.Day - 1} дня, {result.Month - 1} месяцев и {result.Year - 1} лет"; - } - - public static DateTime DateCompare(DateTime date1, DateTime date2) - { - if (date1.Ticks < date2.Ticks) - { - DateTime res = new DateTime(date2.Ticks - date1.Ticks); - return res; - } - - throw new Exception(); - } - - public static string Age(DateTime date) - { - var dateCompar = DateCompare(date, DateTime.Now); - return $"Вам {dateCompar.Day - 1} дня, {dateCompar.Month - 1} месяцев и {dateCompar.Year - 1} лет"; - } - } -} \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index b66e0ee..796cc4d 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -62,7 +62,6 @@ public static void Main(string[] args) } Console.WriteLine("=========="); - Console.WriteLine(AgeClass.Age()); } } } From 7235232e90e31c986730f9e1617ffdbdd14b81e1 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Sun, 29 Dec 2019 17:19:27 +0300 Subject: [PATCH 24/41] =?UTF-8?q?=D0=A1=D1=83=D1=80=D0=BE=D0=B2=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=BF=D0=BE=D0=BB=D0=B8=D0=BC=D0=BE=D1=80=D1=84=D0=B8?= =?UTF-8?q?=D0=B7=D0=BC=20=D0=B8=20=D0=B8=D0=B5=D1=80=D0=B0=D1=80=D1=85?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BD=D0=B0=D1=81=D0=BB=D0=B5=D0=B4=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CourseApp.Tests/AnimalsTest.cs | 60 ++++++++++++++++++++++++++++++++ CourseApp/Animals.cs | 62 ++++++++++++++++++++++++++++++++++ CourseApp/Cat.cs | 61 +++++++++++++++++++++++++++++++++ CourseApp/Dog.cs | 53 ++++++++++------------------- CourseApp/Program.cs | 17 ++++++++++ 5 files changed, 217 insertions(+), 36 deletions(-) create mode 100644 CourseApp.Tests/AnimalsTest.cs create mode 100644 CourseApp/Animals.cs create mode 100644 CourseApp/Cat.cs diff --git a/CourseApp.Tests/AnimalsTest.cs b/CourseApp.Tests/AnimalsTest.cs new file mode 100644 index 0000000..e871ddc --- /dev/null +++ b/CourseApp.Tests/AnimalsTest.cs @@ -0,0 +1,60 @@ +using System; +using Xunit; + +namespace CourseApp.Tests +{ + public class AnimalsTest + { + [Fact] + public void EmptyConstructor() + { + Animals[] animals = new Animals[2]; + animals[0] = new Dog(); + animals[1] = new Cat(); + foreach (Animals animal in animals) + { + Assert.Equal(1, animal.Age); + Assert.Equal("male", animal.Sex); + } + } + + [Fact] + public void OneArgumentConstructor() + { + Animals[] animals = new Animals[2]; + animals[0] = new Dog("White"); + animals[1] = new Cat("Black"); + Assert.Equal("White", animals[0].Name); + Assert.Equal("Black", animals[1].Name); + foreach (Animals animal in animals) + { + Assert.Equal(1, animal.Age); + Assert.Equal("male", animal.Sex); + } + } + + [Fact] + public void ThreeArgumentConstructor() + { + Animals[] animals = new Animals[2]; + animals[0] = new Dog("White", 5, "female"); + animals[1] = new Cat("Black", 2, "male"); + Assert.Equal("White", animals[0].Name); + Assert.Equal("Black", animals[1].Name); + Assert.Equal(5, animals[0].Age); + Assert.Equal(2, animals[1].Age); + Assert.Equal("female", animals[0].Sex); + Assert.Equal("male", animals[1].Sex); + } + + [Fact] + public void ToStringTesting() + { + Animals[] animals = new Animals[2]; + animals[0] = new Dog("White", 5, "female"); + animals[1] = new Cat("Black", 2, "male"); + Assert.Equal("Собака по имени White. Её возраст - 5, пол - женский", animals[0].ToString()); + Assert.Equal("Кот по имени Black. Его возраст - 2, пол - мужской", animals[1].ToString()); + } + } +} \ No newline at end of file diff --git a/CourseApp/Animals.cs b/CourseApp/Animals.cs new file mode 100644 index 0000000..98ee636 --- /dev/null +++ b/CourseApp/Animals.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; + +namespace CourseApp +{ + public abstract class Animals + { + private string sex; + + public Animals() + : this("Test") + { + } + + public Animals(string name) + : this(name, 1, "male") + { + } + + public Animals(string name, int age, string sex) + { + Name = name; + Age = age; + Sex = sex; + } + + public string Name { get; set; } + + public string Sex + { + get + { + return this.sex; + } + + set + { + if (value == "male" || value == "female") + { + this.sex = value; + } + else + { + throw new System.Exception(); + } + } + } + + public virtual int Age { get; set; } + + public new abstract string ToString(); + + public abstract string RunningSpeed(); + + public abstract void Info(); + + public virtual void AgeUp() + { + this.Age++; + } + } +} \ No newline at end of file diff --git a/CourseApp/Cat.cs b/CourseApp/Cat.cs new file mode 100644 index 0000000..f740b3e --- /dev/null +++ b/CourseApp/Cat.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; + +namespace CourseApp +{ + public class Cat : Animals + { + private int age; + + public Cat() + : base() + { + } + + public Cat(string name) + : base(name) + { + } + + public Cat(string name, int age, string sex) + : base(name, age, sex) + { + } + + public override int Age + { + get + { + return this.age; + } + + set + { + if (value > 0 && value < 17) + { + this.age = value; + } + else + { + throw new System.Exception(); + } + } + } + + public override string RunningSpeed() + { + return "Средняя скорость домашнего кота во время бега - 43 - 45 км/ч, максимальная - до 50 км/ч"; + } + + public override string ToString() + { + return (Sex == "male") ? $"Кот по имени {Name}. Его возраст - {Age}, пол - мужской" : $"Кошка по имени {Name}. Её возраст - {Age}, пол - женский"; + } + + public override void Info() + { + Console.WriteLine(this.ToString()); + Console.WriteLine(this.RunningSpeed()); + } + } +} \ No newline at end of file diff --git a/CourseApp/Dog.cs b/CourseApp/Dog.cs index 210a713..e380c5d 100644 --- a/CourseApp/Dog.cs +++ b/CourseApp/Dog.cs @@ -3,51 +3,26 @@ namespace CourseApp { - public class Dog + public class Dog : Animals { private int age; - private string sex; public Dog() - : this("Test") + : base() { } - public Dog(string name, int age, string sex) - { - Name = name; - Age = age; - Sex = sex; - } - public Dog(string name) - : this(name, 1, "male") + : base(name) { } - public string Name { get; set; } - - public string Sex + public Dog(string name, int age, string sex) + : base(name, age, sex) { - get - { - return this.sex; - } - - set - { - if (value == "male") - { - this.sex = value; - } - else - { - throw new System.Exception(); - } - } } - public int Age + public override int Age { get { @@ -56,7 +31,7 @@ public int Age set { - if (value >= 1 && value < 10) + if (value > 0 && value < 14) { this.age = value; } @@ -67,14 +42,20 @@ public int Age } } + public override string RunningSpeed() + { + return "Средняя скорость собаки при беге приблизительно равна 10 - 15 км/час"; + } + public override string ToString() { - return $"Имя:{Name},Возраст:{Age},Пол:{Sex}"; + return (Sex == "male") ? $"Собака по имени {Name}. Его возраст - {Age}, пол - мужской" : $"Собака по имени {Name}. Её возраст - {Age}, пол - женский"; } - public void AgeUp() + public override void Info() { - this.Age++; + Console.WriteLine(this.ToString()); + Console.WriteLine(this.RunningSpeed()); } } -} +} \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 796cc4d..5fa1508 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -62,6 +62,23 @@ public static void Main(string[] args) } Console.WriteLine("=========="); + Console.WriteLine("Введите год своего рождения:"); + int years = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Введите месяц своего рождения:"); + int months = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine("Введите день своего рождения:"); + int days = Convert.ToInt32(Console.ReadLine()); + + Console.WriteLine(AgeClass.Age(days, months, years)); + Console.WriteLine("=========="); + Animals[] animals = new Animals[2]; + animals[0] = new Dog("White", 5, "female"); + animals[1] = new Cat("Black"); + foreach (Animals animal in animals) + { + animal.Info(); + Console.WriteLine(); + } } } } From 75edeab891b36db7209df04db568498df3e6628c Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Sun, 29 Dec 2019 17:24:50 +0300 Subject: [PATCH 25/41] Update dotnetcore.yml --- .github/workflows/dotnetcore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 22cc4eb..c3f5dff 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 2.1.802 + dotnet-version: 3.0.101 - name: Build with dotnet run: | cd CourseApp From b412163a0bc9760f16fcebfc941fa62bbe18b5de Mon Sep 17 00:00:00 2001 From: DeC0re Date: Sun, 29 Dec 2019 17:33:39 +0300 Subject: [PATCH 26/41] Fix --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- CourseApp/CourseApp.csproj | 2 +- CourseApp/Program.cs | 9 --------- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 21e7368..b5e64b9 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -27,4 +27,4 @@ - \ No newline at end of file + diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index c941549..1e655b8 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -20,4 +20,4 @@ - \ No newline at end of file + diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 5fa1508..8840d95 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -61,15 +61,6 @@ public static void Main(string[] args) Console.WriteLine($"y1 = {item}"); } - Console.WriteLine("=========="); - Console.WriteLine("Введите год своего рождения:"); - int years = Convert.ToInt32(Console.ReadLine()); - Console.WriteLine("Введите месяц своего рождения:"); - int months = Convert.ToInt32(Console.ReadLine()); - Console.WriteLine("Введите день своего рождения:"); - int days = Convert.ToInt32(Console.ReadLine()); - - Console.WriteLine(AgeClass.Age(days, months, years)); Console.WriteLine("=========="); Animals[] animals = new Animals[2]; animals[0] = new Dog("White", 5, "female"); From 7a3fe0d88cd9025a6fad7bb0361edfeb955ca439 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Sun, 5 Jan 2020 19:25:16 +0300 Subject: [PATCH 27/41] Fix --- .github/workflows/dotnetcore.yml | 2 +- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- CourseApp/CourseApp.csproj | 2 +- CourseApp/Dog.cs | 61 +++++++++++++++++++++++++- CourseApp/Program.cs | 9 ---- 5 files changed, 63 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 22cc4eb..c3f5dff 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 2.1.802 + dotnet-version: 3.0.101 - name: Build with dotnet run: | cd CourseApp diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 21e7368..b5e64b9 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -27,4 +27,4 @@ - \ No newline at end of file + diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index c941549..1e655b8 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -20,4 +20,4 @@ - \ No newline at end of file + diff --git a/CourseApp/Dog.cs b/CourseApp/Dog.cs index e380c5d..c3e1172 100644 --- a/CourseApp/Dog.cs +++ b/CourseApp/Dog.cs @@ -27,6 +27,35 @@ public override int Age get { return this.age; + public class Dog + { + private int age; + private string sex; + + public Dog() + : this("Test") + { + } + + public Dog(string name, int age, string sex) + { + Name = name; + Age = age; + Sex = sex; + } + + public Dog(string name) + : this(name, 1, "male") + { + } + + public string Name { get; set; } + + public string Sex + { + get + { + return this.sex; } set @@ -34,6 +63,9 @@ public override int Age if (value > 0 && value < 14) { this.age = value; + if (value == "male") + { + this.sex = value; } else { @@ -45,6 +77,24 @@ public override int Age public override string RunningSpeed() { return "Средняя скорость собаки при беге приблизительно равна 10 - 15 км/час"; + public int Age + { + get + { + return this.age; + } + + set + { + if (value >= 1 && value < 10) + { + this.age = value; + } + else + { + throw new System.Exception(); + } + } } public override string ToString() @@ -58,4 +108,13 @@ public override void Info() Console.WriteLine(this.RunningSpeed()); } } -} \ No newline at end of file +} + return $"Имя:{Name},Возраст:{Age},Пол:{Sex}"; + } + + public void AgeUp() + { + this.Age++; + } + } +} diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 5fa1508..8840d95 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -61,15 +61,6 @@ public static void Main(string[] args) Console.WriteLine($"y1 = {item}"); } - Console.WriteLine("=========="); - Console.WriteLine("Введите год своего рождения:"); - int years = Convert.ToInt32(Console.ReadLine()); - Console.WriteLine("Введите месяц своего рождения:"); - int months = Convert.ToInt32(Console.ReadLine()); - Console.WriteLine("Введите день своего рождения:"); - int days = Convert.ToInt32(Console.ReadLine()); - - Console.WriteLine(AgeClass.Age(days, months, years)); Console.WriteLine("=========="); Animals[] animals = new Animals[2]; animals[0] = new Dog("White", 5, "female"); From aad514c30d4c18c381c69fbe38240dbb2819e6b3 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Sun, 5 Jan 2020 19:36:27 +0300 Subject: [PATCH 28/41] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=203.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dotnetcore.yml | 2 +- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- CourseApp/CourseApp.csproj | 2 +- CourseApp/Dog.cs | 61 +------------------------- 4 files changed, 4 insertions(+), 63 deletions(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index c3f5dff..22cc4eb 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.0.101 + dotnet-version: 2.1.802 - name: Build with dotnet run: | cd CourseApp diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index b5e64b9..21e7368 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -27,4 +27,4 @@ - + \ No newline at end of file diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index 1e655b8..c941549 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -20,4 +20,4 @@ - + \ No newline at end of file diff --git a/CourseApp/Dog.cs b/CourseApp/Dog.cs index c3e1172..e380c5d 100644 --- a/CourseApp/Dog.cs +++ b/CourseApp/Dog.cs @@ -27,35 +27,6 @@ public override int Age get { return this.age; - public class Dog - { - private int age; - private string sex; - - public Dog() - : this("Test") - { - } - - public Dog(string name, int age, string sex) - { - Name = name; - Age = age; - Sex = sex; - } - - public Dog(string name) - : this(name, 1, "male") - { - } - - public string Name { get; set; } - - public string Sex - { - get - { - return this.sex; } set @@ -63,9 +34,6 @@ public string Sex if (value > 0 && value < 14) { this.age = value; - if (value == "male") - { - this.sex = value; } else { @@ -77,24 +45,6 @@ public string Sex public override string RunningSpeed() { return "Средняя скорость собаки при беге приблизительно равна 10 - 15 км/час"; - public int Age - { - get - { - return this.age; - } - - set - { - if (value >= 1 && value < 10) - { - this.age = value; - } - else - { - throw new System.Exception(); - } - } } public override string ToString() @@ -108,13 +58,4 @@ public override void Info() Console.WriteLine(this.RunningSpeed()); } } -} - return $"Имя:{Name},Возраст:{Age},Пол:{Sex}"; - } - - public void AgeUp() - { - this.Age++; - } - } -} +} \ No newline at end of file From 94e0eb19c5dd29d52181242fc2292fab0d039093 Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Sun, 5 Jan 2020 19:40:00 +0300 Subject: [PATCH 29/41] Update dotnetcore.yml --- .github/workflows/dotnetcore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 22cc4eb..c3f5dff 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 2.1.802 + dotnet-version: 3.0.101 - name: Build with dotnet run: | cd CourseApp From 871c2d441ca9b53787886b9e930a52f22cbcdc45 Mon Sep 17 00:00:00 2001 From: DeC0re Date: Mon, 13 Apr 2020 12:38:03 +0300 Subject: [PATCH 30/41] interfec --- CourseApp.Tests/AnimalsTest.cs | 13 +++++++++++++ CourseApp/Animals.cs | 27 ++++++++++++++++++++++++++- CourseApp/Cat.cs | 6 ++++++ CourseApp/Dog.cs | 1 + CourseApp/IComparable.cs | 9 +++++++++ CourseApp/IMovable.cs | 9 +++++++++ CourseApp/Program.cs | 15 ++++++++++++--- 7 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 CourseApp/IComparable.cs create mode 100644 CourseApp/IMovable.cs diff --git a/CourseApp.Tests/AnimalsTest.cs b/CourseApp.Tests/AnimalsTest.cs index e871ddc..215cbe3 100644 --- a/CourseApp.Tests/AnimalsTest.cs +++ b/CourseApp.Tests/AnimalsTest.cs @@ -56,5 +56,18 @@ public void ToStringTesting() Assert.Equal("Собака по имени White. Её возраст - 5, пол - женский", animals[0].ToString()); Assert.Equal("Кот по имени Black. Его возраст - 2, пол - мужской", animals[1].ToString()); } + + [Fact] + public void ToCompareTest() + { + Animals[] animals = new Animals[3]; + animals[0] = new Dog("White", 5, "female"); + animals[1] = new Cat("Black", 2, "male"); + animals[2] = new Dog("Black"); + if (animals[0].CompareTo(animals[1]) == 1 && animals[1].CompareTo(animals[2]) == 0) + { + Assert.True(true); + } + } } } \ No newline at end of file diff --git a/CourseApp/Animals.cs b/CourseApp/Animals.cs index 98ee636..db2802d 100644 --- a/CourseApp/Animals.cs +++ b/CourseApp/Animals.cs @@ -3,7 +3,7 @@ namespace CourseApp { - public abstract class Animals + public abstract class Animals : IComparable, IMovable { private string sex; @@ -58,5 +58,30 @@ public virtual void AgeUp() { this.Age++; } + + public virtual void Move() + { + Console.WriteLine("Животное идёт"); + } + + public int CompareTo(object o) + { + Animals animal = o as Animals; + if (animal != null) + { + if (animal.Name == this.Name) + { + return 0; + } + else + { + return 1; + } + } + else + { + throw new Exception("Невозможно сравнить два объекта"); + } + } } } \ No newline at end of file diff --git a/CourseApp/Cat.cs b/CourseApp/Cat.cs index f740b3e..31528ba 100644 --- a/CourseApp/Cat.cs +++ b/CourseApp/Cat.cs @@ -42,6 +42,11 @@ public override int Age } } + public override void Move() + { + Console.WriteLine("Кот крадётся"); + } + public override string RunningSpeed() { return "Средняя скорость домашнего кота во время бега - 43 - 45 км/ч, максимальная - до 50 км/ч"; @@ -56,6 +61,7 @@ public override void Info() { Console.WriteLine(this.ToString()); Console.WriteLine(this.RunningSpeed()); + this.Move(); } } } \ No newline at end of file diff --git a/CourseApp/Dog.cs b/CourseApp/Dog.cs index e380c5d..482363f 100644 --- a/CourseApp/Dog.cs +++ b/CourseApp/Dog.cs @@ -56,6 +56,7 @@ public override void Info() { Console.WriteLine(this.ToString()); Console.WriteLine(this.RunningSpeed()); + this.Move(); } } } \ No newline at end of file diff --git a/CourseApp/IComparable.cs b/CourseApp/IComparable.cs new file mode 100644 index 0000000..93541ff --- /dev/null +++ b/CourseApp/IComparable.cs @@ -0,0 +1,9 @@ +using System; + +namespace CourseApp +{ + public interface IComparable + { + int CompareTo(object o); + } +} \ No newline at end of file diff --git a/CourseApp/IMovable.cs b/CourseApp/IMovable.cs new file mode 100644 index 0000000..e1de7d7 --- /dev/null +++ b/CourseApp/IMovable.cs @@ -0,0 +1,9 @@ +using System; + +namespace CourseApp +{ + public interface IMovable + { + void Move(); + } +} \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 8840d95..a904eb7 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -57,9 +57,9 @@ public static void Main(string[] args) Console.WriteLine("Задание В:"); Console.WriteLine("=========="); foreach (var item in taskBRes) - { - Console.WriteLine($"y1 = {item}"); - } + { + Console.WriteLine($"y1 = {item}"); + } Console.WriteLine("=========="); Animals[] animals = new Animals[2]; @@ -70,6 +70,15 @@ public static void Main(string[] args) animal.Info(); Console.WriteLine(); } + + if (animals[0].CompareTo(animals[1]) == 0) + { + Console.WriteLine("Животные имеют одинаковую кличку"); + } + else + { + Console.WriteLine("Животные имеют разные клички"); + } } } } From e2f268a7583e3567e4638e213ce395e57fe2346b Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:47:42 +0300 Subject: [PATCH 31/41] Update CourseApp.csproj --- CourseApp/CourseApp.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index c941549..626c773 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + netcoreapp3.0.101 True 1573,1591,1701;1702;1705; @@ -20,4 +20,4 @@ - \ No newline at end of file + From e6d706e7c6e3908d82c7e100c90e655e2d707150 Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:48:02 +0300 Subject: [PATCH 32/41] Update CourseApp.Tests.csproj --- CourseApp.Tests/CourseApp.Tests.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 21e7368..c338bcb 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netcoreapp3.0.101 True 1573,1591,1701;1702;1705 false @@ -27,4 +27,4 @@ - \ No newline at end of file + From 986993469837e7e90ee27a4e46534a4da655b398 Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:51:00 +0300 Subject: [PATCH 33/41] Update CourseApp.Tests.csproj --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index c338bcb..b5e64b9 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0.101 + netcoreapp3.0 True 1573,1591,1701;1702;1705 false From 1f4129bee3348eb5fcf1f4cd09ee957ea4acdbe7 Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:51:45 +0300 Subject: [PATCH 34/41] Update CourseApp.csproj --- CourseApp/CourseApp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index 626c773..1e655b8 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0.101 + netcoreapp3.0 True 1573,1591,1701;1702;1705; From 3e2035d3d998731ff788e011328b1d4f6944db8c Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:52:29 +0300 Subject: [PATCH 35/41] Update dotnetcore.yml --- .github/workflows/dotnetcore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index c3f5dff..17b8da1 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.0.101 + dotnet-version: 3.0 - name: Build with dotnet run: | cd CourseApp From a919c3928c40c6e7be61b57e5707489d6d8080af Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:54:44 +0300 Subject: [PATCH 36/41] Update dotnetcore.yml --- .github/workflows/dotnetcore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 17b8da1..502e5ce 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.0 + dotnet-version: 3.0.100 - name: Build with dotnet run: | cd CourseApp From 06a57761472a6c41d6fb5125e91898614f7f321e Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:58:10 +0300 Subject: [PATCH 37/41] Update dotnetcore.yml --- .github/workflows/dotnetcore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 502e5ce..c3f5dff 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.0.100 + dotnet-version: 3.0.101 - name: Build with dotnet run: | cd CourseApp From 60c070c86c1f28b1a67134c9c7be0688fff27ef1 Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:58:31 +0300 Subject: [PATCH 38/41] Update CourseApp.Tests.csproj --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index b5e64b9..0a11bed 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.0 + netcoreapp 3.0 True 1573,1591,1701;1702;1705 false From b1d2689337ed21b78bfca3e3eb984896b1ececd9 Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Mon, 13 Apr 2020 12:58:43 +0300 Subject: [PATCH 39/41] Update CourseApp.csproj --- CourseApp/CourseApp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index 1e655b8..f931650 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + netcoreapp 3.0 True 1573,1591,1701;1702;1705; From fa1392da23fe7c620fe5b8006ea63f56d5b416e7 Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Mon, 13 Apr 2020 13:01:57 +0300 Subject: [PATCH 40/41] Update CourseApp.Tests.csproj --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 0a11bed..5815955 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp 3.0 + netcoreapp 3.1 True 1573,1591,1701;1702;1705 false From 186c63a3bb683aa20608a5e6bdbd36f1e2706bd7 Mon Sep 17 00:00:00 2001 From: Vladislav Savchenko <55225959+DeC0re@users.noreply.github.com> Date: Mon, 13 Apr 2020 13:02:11 +0300 Subject: [PATCH 41/41] Update CourseApp.csproj --- CourseApp/CourseApp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index f931650..4119573 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp 3.0 + netcoreapp 3.1 True 1573,1591,1701;1702;1705;