From cca060b9159f2f5b26ba91345a8bb5100bf95404 Mon Sep 17 00:00:00 2001 From: Nastya Kasatkina Date: Wed, 8 Jan 2020 16:48:06 +0300 Subject: [PATCH 1/4] Lab1 --- .github/workflows/dotnetcore.yml | 23 +++ .gitignore | 205 +++++++++++++++++++++++++ CourseApp.Tests/CourseApp.Tests.csproj | 30 ++++ CourseApp.Tests/DemoTest.cs | 57 +++++++ CourseApp.Tests/PlatypusTest.cs | 55 +++++++ CourseApp/.vscode/launch.json | 25 +++ CourseApp/.vscode/tasks.json | 42 +++++ CourseApp/CourseApp.csproj | 23 +++ CourseApp/CourseApp.sln | 31 ++++ CourseApp/Platypus.cs | 60 ++++++++ CourseApp/Program.cs | 68 ++++++++ _stylecop/stylecop.json | 12 ++ _stylecop/stylecop.ruleset | 14 ++ courseworkspace.code-workspace | 11 ++ git | 30 ++++ 15 files changed, 686 insertions(+) create mode 100644 .github/workflows/dotnetcore.yml create mode 100644 .gitignore create mode 100644 CourseApp.Tests/CourseApp.Tests.csproj create mode 100644 CourseApp.Tests/DemoTest.cs 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/CourseApp.csproj create mode 100644 CourseApp/CourseApp.sln create mode 100644 CourseApp/Platypus.cs create mode 100644 CourseApp/Program.cs create mode 100644 _stylecop/stylecop.json create mode 100644 _stylecop/stylecop.ruleset create mode 100644 courseworkspace.code-workspace create mode 100644 git diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml new file mode 100644 index 0000000..502e5ce --- /dev/null +++ b/.github/workflows/dotnetcore.yml @@ -0,0 +1,23 @@ +name: .NET Core + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.0.100 + - name: Build with dotnet + run: | + cd CourseApp + dotnet build --configuration Release + - name: Run tests + run: | + cd CourseApp.Tests + dotnet test 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 new file mode 100644 index 0000000..372ec0e --- /dev/null +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -0,0 +1,30 @@ + + + + netcoreapp3.0 + True + 1573,1591,1701;1702;1705 + false + + + + + + + + + + + + + + + ../_stylecop/stylecop.ruleset + true + + + + + + + diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs new file mode 100644 index 0000000..68d5c89 --- /dev/null +++ b/CourseApp.Tests/DemoTest.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using Xunit; + +namespace CourseApp.Tests +{ + public class DemoTest + { + [Fact] + public void TestFunc() + { + var res = Program.MyFunction(0, 0); + Assert.Equal(double.PositiveInfinity, res, 3); + } + + [Fact] + public void TestTaskA() + { + double a = 2; + double xn = 1.2; + double xk = 4.2; + double dx = 0.6; + List res = Program.TaskA(a, xn, xk, dx); + List exp = new List { 0.024919580136386867, 0.02327901792977313, 0.02138591667754329, 0.019542362678459768, 0.01785029731362981 }; + for (int i = 0; i < exp.Count; i++) + { + Assert.Equal(exp[i], res[i], 3); + } + } + + [Fact] + public void TestTastAUncorrect() + { + List res = Program.TaskA(3, 4.2, 1.2, 0.7); + Assert.Equal(new List(), res); + } + + [Fact] + public void TestTaskB() + { + List xB = new List { 1.16, 1.32, 1.47, 1.65, 1.93 }; + List res = Program.TaskB(2, xB); + List exp = new List { 0.025004724857363752, 0.024639361870982292, 0.024247019851321865, 0.023732277381772752, 0.022875026963062515 }; + for (int i = 0; i < exp.Count; i++) + { + Assert.Equal(exp[i], res[i], 3); + } + } + + [Fact] + public void TestZeroLengthB() + { + var res = Program.TaskB(0, new List()); + Assert.Empty(res); + } + } +} 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/CourseApp.csproj b/CourseApp/CourseApp.csproj new file mode 100644 index 0000000..f01046b --- /dev/null +++ b/CourseApp/CourseApp.csproj @@ -0,0 +1,23 @@ + + + + Exe + netcoreapp3.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..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/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 new file mode 100644 index 0000000..215d78d --- /dev/null +++ b/CourseApp/Program.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; + +namespace CourseApp +{ + public class Program + { + public static double MyFunction(double a, double x) + { + var c = Math.Pow(Math.Log10(a + x), 2) / Math.Pow(a + x, 2); + return c; + } + + public static List TaskA ( + double a, + double xn, + double xk, + double dx) + { + var steps = (int)Math.Floor((xk - xn) / dx); + var y = new List(); + var i = 0; + for (var x = xn; x < xk; x += dx) + { + y.Add(MyFunction(a, x)); + i++; + } + + return y; + } + + public static List TaskB ( + double a, + List x) + { + var y = new List(); + for (int i = 0; i < x.Count; i++) + { + y.Add(MyFunction(a, x[i])); + } + + return y; + } + + public static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + var taskA = TaskA(2, 1.2, 4.2, 0.6); + + for (var i = 0; i < taskA.Count; i++) + { + Console.WriteLine($"y={taskA[i]}"); + } + + var xB = new List { 1.16, 1.32, 1.47, 1.65, 1.93 }; + var taskB = TaskB(2, xB); + for (var i = 0; i < xB.Count; i++) + { + Console.WriteLine($"x={xB[i]} y={taskB[i]}"); + } + + var item = new Platypus(); + Console.WriteLine(item.View()); + + Console.ReadLine(); + } + } +} diff --git a/_stylecop/stylecop.json b/_stylecop/stylecop.json new file mode 100644 index 0000000..4a96e8f --- /dev/null +++ b/_stylecop/stylecop.json @@ -0,0 +1,12 @@ +{ + "$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 + } + } +} \ No newline at end of file diff --git a/_stylecop/stylecop.ruleset b/_stylecop/stylecop.ruleset new file mode 100644 index 0000000..98806c8 --- /dev/null +++ b/_stylecop/stylecop.ruleset @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/courseworkspace.code-workspace b/courseworkspace.code-workspace new file mode 100644 index 0000000..4f9af01 --- /dev/null +++ b/courseworkspace.code-workspace @@ -0,0 +1,11 @@ +{ + "folders": [ + { + "path": "CourseApp" + }, + { + "path": "CourseApp.Tests" + } + ], + "settings": {} +} \ No newline at end of file diff --git a/git b/git new file mode 100644 index 0000000..8467781 --- /dev/null +++ b/git @@ -0,0 +1,30 @@ +* master + remotes/origin/Aleksandr_Enivatov + remotes/origin/Aleksandr_Ermakov + remotes/origin/Aleksandr_Gruzdev + remotes/origin/Aleksej_Merzljakov + remotes/origin/Alena_Krutikova + remotes/origin/Alena_Sheshotova + remotes/origin/Anastasija_Kasatkina + remotes/origin/Anatolij_Tkachev + remotes/origin/Anna_Kubova + remotes/origin/Anton_Lapshov + remotes/origin/Daniil_Tretjakov + remotes/origin/Denis_Oreshnikov + remotes/origin/Dmitrij_Nazarov + remotes/origin/Dmitrij_Ovsjanik + remotes/origin/Evgenij_Satyev + remotes/origin/Fedor_Tomash + remotes/origin/HEAD -> origin/master + remotes/origin/Ilja_Raskatov + remotes/origin/Konstantin_Tjukalov + remotes/origin/Ksenija_Kochina + remotes/origin/Marija_Popova + remotes/origin/Svetlana_Nesheva + remotes/origin/Valerija_Kiseleva + remotes/origin/Veniamin_Kolmogorov + remotes/origin/Viktor_Morohovtsev + remotes/origin/Vladislav_Savchenko + remotes/origin/jskonst + remotes/origin/jskonst-patch-1 + remotes/origin/master From 9219d64daa112333b9bbc9f00405664d46faf435 Mon Sep 17 00:00:00 2001 From: Nastya Kasatkina Date: Wed, 8 Jan 2020 17:32:05 +0300 Subject: [PATCH 2/4] lab2 --- CourseApp.Tests/MouseTest.cs | 65 +++++++++++++++++++++++++++++ CourseApp.Tests/PlatypusTest.cs | 55 ------------------------ CourseApp/{Platypus.cs => Mouse.cs} | 36 ++++++++++------ CourseApp/Program.cs | 4 +- 4 files changed, 91 insertions(+), 69 deletions(-) create mode 100644 CourseApp.Tests/MouseTest.cs delete mode 100644 CourseApp.Tests/PlatypusTest.cs rename CourseApp/{Platypus.cs => Mouse.cs} (53%) diff --git a/CourseApp.Tests/MouseTest.cs b/CourseApp.Tests/MouseTest.cs new file mode 100644 index 0000000..9941694 --- /dev/null +++ b/CourseApp.Tests/MouseTest.cs @@ -0,0 +1,65 @@ +using System; +using Xunit; + +namespace CourseApp.Tests +{ + public class MouseTest + { + [Fact] + public void TestEmptyConstructor() + { + var item = new Mouse(); + Assert.Equal(0, item.Age); + Assert.Equal("Untitled", item.Name); + Assert.True(item.IsMale); + } + + [Fact] + public void TestView() + { + var item = new Mouse(); + var view = "```оО````\n ```•._)~``\n ``````````"; + Assert.Equal(view, item.View()); + } + + [Fact] + public void TestSetAge() + { + var item = new Mouse(); + item.Age = 5; + Assert.Equal(5, item.Age); + } + + [Fact] + public void TestIncorrectSetAge() + { + var item = new Mouse(); + try + { + item.Age = -5; + } + catch (System.Exception) + { + Assert.True(true); + } + + Assert.Equal(0, item.Age); + } + + [Fact] + public void TestPeep() + { + var item = new Mouse(); + Assert.Equal("Mouse squeaks.", item.Peep()); + } + + [Fact] + public void TestToString() + { + var item = new Mouse(); + Assert.Equal("The mouse's name is Untitled.He is 0 years old.", item.ToString()); + item.IsMale = false; + Assert.Equal("The mouse's name is Untitled.She is 0 years old.", item.ToString()); + } + } +} 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/Platypus.cs b/CourseApp/Mouse.cs similarity index 53% rename from CourseApp/Platypus.cs rename to CourseApp/Mouse.cs index eb3d463..ea16698 100644 --- a/CourseApp/Platypus.cs +++ b/CourseApp/Mouse.cs @@ -2,16 +2,16 @@ namespace CourseApp { - public class Platypus + public class Mouse { private int age; - public Platypus() + public Mouse() : this(0, "Untitled", true) { } - public Platypus(int age, string name, bool isMale) + public Mouse(int age, string name, bool isMale) { Name = name; Age = age; @@ -35,26 +35,36 @@ public int Age } else { - Console.WriteLine("Age should be > 0 and < than 20"); + throw new System.Exception("Age should be > 0 and < than 20"); } } } public bool IsMale { get; set; } - public bool IsPoisoned + public string View() { - get { return this.IsMale; } + return "```оО````\n ```•._)~``\n ``````````"; } - public string View() + public string Peep() + { + return "Mouse squeaks."; + } + + public override string ToString() { - return @" - _.-^~~^^^`~-,_,,~''''''```~,''``~'``~, - ______,' -o :. _ . ; ,'`, `. -( -\.._,.;;'._ ,( } _`_-_,, `, `, - ``~~~~~~' ((/'((((____/~~~~~~'(,(,___> `~' - "; + string s; + if (this.IsMale) + { + s = "He"; + } + else + { + s = "She"; + } + + return $"The mouse's name is {Name}.{s} is {Age} years old."; } } } \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 215d78d..683633a 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -59,8 +59,10 @@ public static void Main(string[] args) Console.WriteLine($"x={xB[i]} y={taskB[i]}"); } - var item = new Platypus(); + var item = new Mouse(); + Console.WriteLine(item.ToString()); Console.WriteLine(item.View()); + Console.WriteLine(item.Peep()); Console.ReadLine(); } From d50728dac17bc15113a7050e79e93d44a078ac41 Mon Sep 17 00:00:00 2001 From: Nastya Kasatkina Date: Thu, 9 Jan 2020 17:07:44 +0300 Subject: [PATCH 3/4] fix --- .gitignore | 3 +++ CourseApp/Program.cs | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 24cb440..8b26437 100644 --- a/.gitignore +++ b/.gitignore @@ -200,6 +200,9 @@ $RECYCLE.BIN/ # Added by Jskonst Properties/ +#Added Anastasia +git.* + ##### # 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/Program.cs b/CourseApp/Program.cs index 683633a..f96a6e7 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -17,13 +17,10 @@ public static List TaskA ( double xk, double dx) { - var steps = (int)Math.Floor((xk - xn) / dx); var y = new List(); - var i = 0; for (var x = xn; x < xk; x += dx) { y.Add(MyFunction(a, x)); - i++; } return y; From 3d513caef4b9bb73768ec987b3e01ed4eafa0186 Mon Sep 17 00:00:00 2001 From: Nastya Kasatkina Date: Thu, 9 Jan 2020 17:25:50 +0300 Subject: [PATCH 4/4] fixignore --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8b26437..b3d563b 100644 --- a/.gitignore +++ b/.gitignore @@ -144,7 +144,7 @@ UpgradeLog*.htm *.txt~ *.swp *.swo - + # svn .svn @@ -201,7 +201,7 @@ $RECYCLE.BIN/ Properties/ #Added Anastasia -git.* +git ##### # End of core ignore list, below put you custom 'per project' settings (patterns or path)