diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml new file mode 100644 index 0000000..22cc4eb --- /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: 2.1.802 + - 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/ConsoleApp /Bishop.cs b/ConsoleApp /Bishop.cs new file mode 100644 index 0000000..7e0fdc7 --- /dev/null +++ b/ConsoleApp /Bishop.cs @@ -0,0 +1,18 @@ +namespace ExamApp +{ + public class Bishop : Chessmen + { + public Bishop() + { + this.X = 0; + this.Y = 0; + } + + public override string Name { get; set; } = "Слон"; + + public override void Move() + { + Y += 2; + } + } +} diff --git a/ConsoleApp /Rook.cs b/ConsoleApp /Rook.cs new file mode 100644 index 0000000..b4728e4 --- /dev/null +++ b/ConsoleApp /Rook.cs @@ -0,0 +1,16 @@ +namespace ExamApp +{ + public class Rook : Chessmen + { + public Rook() + { + this.X = 0; + this.Y = 0; + } + public override string Name { get; set; } = "Ладья"; + public override void Move() + { + this.Y += 2; + } + } +} diff --git a/ConsoleApp.Tests/ConsoleApp.Tests.csproj b/ConsoleApp.Tests/ConsoleApp.Tests.csproj new file mode 100644 index 0000000..24bc394 --- /dev/null +++ b/ConsoleApp.Tests/ConsoleApp.Tests.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp2.0 + + false + + + + + + + + + + + + + + diff --git a/ConsoleApp.Tests/Tests.cs b/ConsoleApp.Tests/Tests.cs new file mode 100644 index 0000000..c854ed6 --- /dev/null +++ b/ConsoleApp.Tests/Tests.cs @@ -0,0 +1,39 @@ +using Xunit; +using System; +using ExamApp; + +namespace ExamApp.Tests +{ + public class UnitTest1 + { + [Fact] + public void CurrentBishopCoordinatesTest() + { + var a = new Bishop(); + Equals(0, a.X); + } + [Fact] + public void CurrentNameTest() + { + var a = new Rook(); + Equals("Ладья", a.Name); + } + + [Fact] + public void CurrMoveTest() + { + var a = new Pawn(); + a.Move(); + Equals(3, a.X); + } + + [Fact] + public void EatTest() + { + var a = new Pawn(); + var b = new Bishop(); + a.Eat(b); + Equals(!b.IsAlive); + } + } +} diff --git a/ConsoleApp/Chessmen.cs b/ConsoleApp/Chessmen.cs new file mode 100644 index 0000000..9caa34b --- /dev/null +++ b/ConsoleApp/Chessmen.cs @@ -0,0 +1,36 @@ +namespace ExamApp +{ + public abstract class Chessmen : IMoves + { + int x, y; + + public bool IsAlive { get; set; } = true; + + public abstract string Name { get; set; } + + public int X + { + get { return this.x; } + set + { + if (value >= 0 && value <= 8) this.x = value; + else throw new System.ArgumentOutOfRangeException("uncorrect value"); + } + } + public int Y + { + get { return this.y; } + set + { + if (value >= 0 && value <= 8) this.y = value; + else throw new System.ArgumentOutOfRangeException("uncorrect value"); + } + } + public abstract void Move(); + + public void Eat(Chessmen who) + { + who.IsAlive = false; + } + } +} \ No newline at end of file diff --git a/ConsoleApp/ConsoleApp.csproj b/ConsoleApp/ConsoleApp.csproj new file mode 100644 index 0000000..cf32e1e --- /dev/null +++ b/ConsoleApp/ConsoleApp.csproj @@ -0,0 +1,13 @@ + + + + Exe + netcoreapp2.1 + 7.2 + + + + + + + diff --git a/ConsoleApp/IMoves.cs b/ConsoleApp/IMoves.cs new file mode 100644 index 0000000..a68457c --- /dev/null +++ b/ConsoleApp/IMoves.cs @@ -0,0 +1,9 @@ +namespace ExamApp +{ + public interface IMoves + { + void Move(); + + void Eat(Chessmen who); + } +} \ No newline at end of file diff --git a/ConsoleApp/Knight.cs b/ConsoleApp/Knight.cs new file mode 100644 index 0000000..4bf4681 --- /dev/null +++ b/ConsoleApp/Knight.cs @@ -0,0 +1,17 @@ +namespace ExamApp +{ + public class Pawn : Chessmen + { + public Pawn() + { + Y = 0; + X = 0; + } + public override string Name { get; set; } = "Пешка"; + public override void Move() + { + Y += 1; + X = 0; + } + } +} \ No newline at end of file diff --git a/ConsoleApp/Program.cs b/ConsoleApp/Program.cs new file mode 100644 index 0000000..bb0fb25 --- /dev/null +++ b/ConsoleApp/Program.cs @@ -0,0 +1,21 @@ +using System; + +namespace ExamApp +{ + class Program + { + static void Main(string[] args) + { + var a = new Bishop(); + Console.WriteLine(a.X); + + var b = new Pawn(); + Console.WriteLine(b.Y); + + var c = new Rook(); + Console.WriteLine(c.Y); + + Console.ReadLine(); + } + } +} diff --git a/README.md b/README.md index f097ac3..ed97e8c 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# exam_147_2020 \ No newline at end of file +# Kasatkina \ No newline at end of file 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..b3042c3 --- /dev/null +++ b/courseworkspace.code-workspace @@ -0,0 +1,11 @@ +{ + "folders": [ + { + "path": "ConsoleApp" + }, + { + "path": "ConsoleApp.Tests" + } + ], + "settings": {} +} \ No newline at end of file