From 9969670dd4b2216a54fb1b08f0256eef8f0799f0 Mon Sep 17 00:00:00 2001 From: jskonst Date: Sun, 9 Dec 2018 21:57:24 +0300 Subject: [PATCH 01/18] Added stylecop for project --- CourseApp/CourseApp.csproj | 15 +++++++++++++++ CourseApp/Program.cs | 5 +++-- stylecop.json | 15 +++++++++++++++ stylecop.ruleset | 21 +++++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 stylecop.json create mode 100644 stylecop.ruleset diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index 23df604..7afbee9 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -3,6 +3,21 @@ Exe netcoreapp2.1 + True + 1573,1591,1701;1702;1705 + + + + + + ../stylecop.ruleset + true + + + + + + diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 3f81738..248bbe4 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -2,11 +2,12 @@ namespace CourseApp { - class Program + public class Program { - static void Main(string[] args) + public static void Main(string[] args) { Console.WriteLine("Hello World!"); + Console.ReadLine(); } } } diff --git a/stylecop.json b/stylecop.json new file mode 100644 index 0000000..643b8c1 --- /dev/null +++ b/stylecop.json @@ -0,0 +1,15 @@ +{ + "$schema": + "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", + "settings": { + "documentationRules": { + "documentExposedElements": false, + "documentInterfaces": false, + "companyName": "Test Company", + "copyrightText": + "This source code is Copyright © {companyName} and MAY NOT be copied, reproduced,\npublished, distributed or transmitted to or stored in any manner without prior\nwritten consent from {companyName} (www.yourcompany.com).", + "xmlHeader": false + } + }, + "additionalArguments": ["./stylecop.ruleset", "./stylecop.json"] +} diff --git a/stylecop.ruleset b/stylecop.ruleset new file mode 100644 index 0000000..b36938e --- /dev/null +++ b/stylecop.ruleset @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From c4a7f5d3aa7f62afd675dbc5c4fb29d24362f97e Mon Sep 17 00:00:00 2001 From: jskonst Date: Tue, 11 Dec 2018 11:21:14 +0300 Subject: [PATCH 02/18] Added stylecop for project --- CourseApp.Tests/CourseApp.Tests.csproj | 30 +++++++++++++++++++ CourseApp.Tests/DemoTest.cs | 14 +++++++++ CourseApp/CourseApp.csproj | 6 ++-- stylecop.json => stylecop/stylecop.json | 0 stylecop.ruleset => stylecop/stylecop.ruleset | 1 + 5 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 CourseApp.Tests/CourseApp.Tests.csproj create mode 100644 CourseApp.Tests/DemoTest.cs rename stylecop.json => stylecop/stylecop.json (100%) rename stylecop.ruleset => stylecop/stylecop.ruleset (95%) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj new file mode 100644 index 0000000..dcfd1f9 --- /dev/null +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -0,0 +1,30 @@ + + + + netcoreapp2.2 + 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..09e415e --- /dev/null +++ b/CourseApp.Tests/DemoTest.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace CourseApp.Tests +{ + public class DemoTest + { + [Fact] + public void Test1() + { + Assert.True(true); + } + } +} diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index 7afbee9..cc0df39 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -8,16 +8,16 @@ - + - ../stylecop.ruleset + ../stylecop/stylecop.ruleset true - + diff --git a/stylecop.json b/stylecop/stylecop.json similarity index 100% rename from stylecop.json rename to stylecop/stylecop.json diff --git a/stylecop.ruleset b/stylecop/stylecop.ruleset similarity index 95% rename from stylecop.ruleset rename to stylecop/stylecop.ruleset index b36938e..3350d0e 100644 --- a/stylecop.ruleset +++ b/stylecop/stylecop.ruleset @@ -15,6 +15,7 @@ + From 2c90b1b251fca14fc4b9df6388d898f857f1c4e5 Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Sat, 29 Dec 2018 12:44:32 +0300 Subject: [PATCH 03/18] Added StyleCop --- CourseApp.Tests/CourseApp.Tests.csproj | 25 ++-------------- CourseApp.Tests/UnitTest1.cs | 7 +++++ CourseApp/CourseApp.csproj | 10 +++---- CourseApp/Laba2.cs | 40 -------------------------- CourseApp/Program.cs | 32 ++++++++++++++++++--- 5 files changed, 41 insertions(+), 73 deletions(-) delete mode 100644 CourseApp/Laba2.cs diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index cda8067..06ae7e5 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -1,27 +1,7 @@ -HEAD - - - - netcoreapp2.1 - - false - - - - - - - - - - - - - - netcoreapp2.2 + netcoreapp2.0 True 1573,1591,1701;1702;1705 false @@ -47,5 +27,4 @@ - - master + \ No newline at end of file diff --git a/CourseApp.Tests/UnitTest1.cs b/CourseApp.Tests/UnitTest1.cs index cc24ccb..aaa70d3 100644 --- a/CourseApp.Tests/UnitTest1.cs +++ b/CourseApp.Tests/UnitTest1.cs @@ -16,42 +16,49 @@ public void Test1() var res = Program.Func(0.0, 0.8, 0.4); Assert.Equal(0.283, res, 3); } + [Fact] public void Test2() { var res = Program.Func(0.0, 1.1, 0.1); Assert.Equal(0.639, res, 3); } + [Fact] public void Test3() { var res = Program.Func(0.1, 0.4, 0.3); Assert.Equal(0.063, res, 3); } + [Fact] public void Test4() { var res = Program.Func(2.2, 1.8, 3.4); Assert.Equal(203.09, res, 3); } + [Fact] public void Test5() { var res = Program.Func(0.09, 0.71, 0.2); Assert.Equal(0.224, res, 3); } + [Fact] public void Test6() { var res = Program.Func(0.0, 0.01, 0.33); Assert.Equal(0.0, res, 3); } + [Fact] public void Test7() { var res = Program.Func(0.9, 0.8, 0.7); Assert.Equal(1.266, res, 3); } + [Fact] public void Test8() { diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index 1306f48..23b45ed 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -2,25 +2,23 @@ Exe -HEAD netcoreapp2.0 - netcoreapp2.1 True 1573,1591,1701;1702;1705 -master - - + + ../stylecop/stylecop.ruleset true + - + diff --git a/CourseApp/Laba2.cs b/CourseApp/Laba2.cs deleted file mode 100644 index b44b739..0000000 --- a/CourseApp/Laba2.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace CourseApp -{ - - public class Program - { - static void Main(string[] args) - { - double a = 2.5; - double b = 4.6; - - // ЗАДАНИЕ А - - Console.WriteLine("ЗАДАНИЕ А"); - for (double x = 1.1; x <= 3.6; x += 0.5) - { - Console.WriteLine($"y({x})={Func(x, a, b)}"); - } - - // ЗАДАНИЕ В - - Console.WriteLine("ЗАДАНИЕ В"); - double[] mas = new double[] { 1.2, 1.28, 1.36, 1.46, 2.35 }; - foreach (double x in mas) - { - Console.WriteLine($"y({x})={Func(x, a, b)}"); - } - Console.ReadKey(); - } - public static double Func(double x, double a, double b) - { - return ((a + b * x) * (a + b * x) * ((a + b * x) / 2)) / (1 + Math.Log10(a + b * x)); - } - } -} diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 248bbe4..6d57c16 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,13 +1,37 @@ using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace CourseApp { - public class Program +public class Program { - public static void Main(string[] args) + public static double Func(double x, double a, double b) { - Console.WriteLine("Hello World!"); - Console.ReadLine(); + return ((a + (b * x)) * (a + (b * x)) * ((a + (b * x)) / 2)) / (1 + Math.Log10(a + (b * x))); + } + + private static void Main(string[] args) + { + double a = 2.5; + double b = 4.6; + + Console.WriteLine("ЗАДАНИЕ А"); + for (double x = 1.1; x <= 3.6; x += 0.5) + { + Console.WriteLine($"y({x})={Func(x, a, b)}"); + } + + Console.WriteLine("ЗАДАНИЕ В"); + double[] mas = new double[] { 1.2, 1.28, 1.36, 1.46, 2.35 }; + foreach (double x in mas) + { + Console.WriteLine($"y({x})={Func(x, a, b)}"); + } + + Console.ReadKey(); } } } From 62d376d83deb52649db156be0361d80f8b953e14 Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Sun, 30 Dec 2018 12:45:39 +0300 Subject: [PATCH 04/18] Added class ship --- .gitattributes | 63 ++++++++++++++++++++++++++++++ CourseApp/Program.cs | 11 +++--- CourseApp/Ship.cs | 92 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+), 6 deletions(-) create mode 100644 .gitattributes create mode 100644 CourseApp/Ship.cs diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 6d57c16..0a6e5a9 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -1,12 +1,9 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using CourseApp; namespace CourseApp { -public class Program + public class Program { public static double Func(double x, double a, double b) { @@ -31,7 +28,9 @@ private static void Main(string[] args) Console.WriteLine($"y({x})={Func(x, a, b)}"); } - Console.ReadKey(); + Ship admiral = new Ship(40); + admiral.Info(); + Console.ReadLine(); } } } diff --git a/CourseApp/Ship.cs b/CourseApp/Ship.cs new file mode 100644 index 0000000..b75998e --- /dev/null +++ b/CourseApp/Ship.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CourseApp +{ + public class Ship + { + private int passangers; + private int dlina; + private int vodoizmeschenie; + + public Ship() + { + passangers = 20; + dlina = 50; + vodoizmeschenie = 100; + } + + public Ship(int b) + { + passangers = 25; + dlina = b; + vodoizmeschenie = 100; + } + + public Ship(int a, int b, int c) + { + passangers = a; + dlina = b; + vodoizmeschenie = c; + } + + public void Info() + { + Console.WriteLine($" пассажиров: {passangers} длина: {dlina} водоизмещение: {vodoizmeschenie}"); + Console.WriteLine(ToString()); + Console.WriteLine(Ris()); + } + + public override string ToString() + { + return $"Корабль с длиной {dlina} метров вышел в открытое море"; + } + + public string Ris() + { + return @"_¶¶¶ +_____________________¶ +_____________________¶¶¶¶¶¶¶¶¶¶¶¶¶ +_____________________¶¶¶___¶__¶_¶¶¶¶ +_____________________¶¶¶___¶¶¶¶___¶¶ +_____________________¶¶¶__¶¶¶¶¶___¶¶ +_____________________¶¶¶__¶¶¶¶¶___¶ +_____________________¶¶¶¶¶¶__¶¶___¶ +_____________________¶_________¶¶¶¶ +_____________¶¶¶¶¶¶¶¶¶¶¶¶¶ +_____________¶¶___________¶¶ +______________¶____________¶ +______________¶_____________¶ +_______________¶____________¶ +_______________¶____________¶_¶¶ +_______________¶__¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶ +_____¶¶¶¶¶¶¶¶¶¶¶¶¶¶______________¶ +_____¶____________¶¶_____________¶¶____¶ +_____¶¶____________¶_____¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶ +______¶______¶¶¶¶¶¶¶¶¶¶¶¶¶¶______________¶ +______¶¶_____¶¶___________¶______________¶¶ +_______¶______¶____________¶______________¶ +_______¶______¶¶___________¶_____________¶¶ +_______¶_______¶___________¶_____________¶¶ +______¶¶_______¶___________¶¶____________¶ +______¶¶¶¶¶¶¶¶¶¶¶__________¶¶___________¶¶ +___________¶_¶_¶¶________¶¶¶_____¶¶¶¶¶¶¶¶_____¶¶¶ +___________¶_¶_¶¶¶¶¶¶¶¶¶¶¶_¶¶¶¶¶¶¶_______¶¶¶¶¶__¶¶ +¶¶¶¶¶¶_____¶_¶______¶¶_¶_______¶_¶¶¶¶¶¶¶¶¶___¶¶¶¶¶ +¶¶___¶¶¶¶¶¶¶¶¶______¶¶_¶____¶¶¶¶¶¶¶________¶¶ +__¶¶________¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶____¶¶______¶ +____¶____________________________¶¶_¶____¶ +_____¶_____¶¶¶_____¶¶_____¶¶¶_____¶¶¶___¶¶ +______¶___¶¶_¶¶___¶¶_¶____¶_¶¶__________¶ +______¶¶____¶¶_____¶¶¶_____¶¶__________¶¶ +_______¶¶_____________________________¶¶ +________¶¶___________________________¶¶ +_________¶¶________________________¶¶¶ +___________¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶ +"; + } + } +} From f46561dcba164fa82f08b97d6fcc1d8687e7380f Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Thu, 3 Jan 2019 11:07:27 +0300 Subject: [PATCH 05/18] Just a lil update --- CourseApp.Tests/CourseApp.Tests.csproj | 2 +- CourseApp.Tests/UnitTest1.cs | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj index 06ae7e5..76f7dc6 100644 --- a/CourseApp.Tests/CourseApp.Tests.csproj +++ b/CourseApp.Tests/CourseApp.Tests.csproj @@ -1,4 +1,4 @@ - + netcoreapp2.0 diff --git a/CourseApp.Tests/UnitTest1.cs b/CourseApp.Tests/UnitTest1.cs index aaa70d3..5ceb1d1 100644 --- a/CourseApp.Tests/UnitTest1.cs +++ b/CourseApp.Tests/UnitTest1.cs @@ -1,12 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Xunit; using CourseApp; -namespace CourseApp.Test +namespace CourseApp.Tests { public class UnitTest1 { From bbab0793e364ba7afb947460811279d64b182396 Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Thu, 3 Jan 2019 13:22:38 +0300 Subject: [PATCH 06/18] Modified Ship.cs and added UnitTest2 --- CourseApp.Tests/UnitTest2.cs | 90 ++++++++++++++++++++++++++++++++++++ CourseApp/Ship.cs | 63 +++++++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 CourseApp.Tests/UnitTest2.cs diff --git a/CourseApp.Tests/UnitTest2.cs b/CourseApp.Tests/UnitTest2.cs new file mode 100644 index 0000000..b6e1dc6 --- /dev/null +++ b/CourseApp.Tests/UnitTest2.cs @@ -0,0 +1,90 @@ +using System; +using Xunit; +using CourseApp; + +namespace CourseApp.Tests +{ + public class UnitTest2 + { + [Fact] + public void Test9() + { + Ship admiral = new Ship(); + var resRis = admiral.Ris(); + Assert.Equal( + @"_ +_____________________ +_____________________ +___________________________ +___________________________ +__________________________ +__________________________ +__________________________ +______________________________ +_____________ +________________________ +__________________________ +___________________________ +___________________________ +____________________________ +_________________ +___________________ +__________________________________ +______________________ +__________________________ +____________________________________ +_______________________________________ +_____________________________________ +______________________________________ +____________________________________ +___________________________ +_______________________________ +_______________________ +________________________ +______________________ +____________________ +_____________________________________ +____________________________ +_____________________________ +______________________________ +____________________________________ +___________________________________ +_________________________________ +___________ +", resRis); + } + + [Fact] + public void Test10() + { + Ship admiral = new Ship(40); + var passangers = admiral.Passangers; + var dlina = admiral.Dlina; + var vodoizmeschenie = admiral.Vodoizmeschenie; + Assert.Equal(25, passangers); + Assert.Equal(40, dlina); + Assert.Equal(100, vodoizmeschenie); + } + + [Fact] + public void Test11() + { + Ship admiral = new Ship(); + var passangers = admiral.Passangers; + var dlina = admiral.Dlina; + var vodoizmeschenie = admiral.Vodoizmeschenie; + Assert.Equal(20, passangers); + Assert.Equal(50, dlina); + Assert.Equal(100, vodoizmeschenie); + } + + [Fact] + public void Test12() + { + Ship admiral = new Ship(); + var resToString = admiral.ToString(); + var dlina = admiral.Dlina; + Assert.Equal($" {dlina} ", resToString); + } + } +} \ No newline at end of file diff --git a/CourseApp/Ship.cs b/CourseApp/Ship.cs index b75998e..6617d89 100644 --- a/CourseApp/Ship.cs +++ b/CourseApp/Ship.cs @@ -33,6 +33,69 @@ public Ship(int a, int b, int c) vodoizmeschenie = c; } + public int Passangers + { + get + { + return passangers; + } + + set + { + if (value > 250 || value < 0) + { + Console.WriteLine("Невозможное количество пассажиров(min:0 max:250)"); + throw new Exception(); + } + else + { + passangers = value; + } + } + } + + public int Dlina + { + get + { + return dlina; + } + + set + { + if (value > 1000 || value < 5) + { + Console.WriteLine("Невозможная длина корабля(min:5 max:1000)"); + throw new Exception(); + } + else + { + dlina = value; + } + } + } + + public int Vodoizmeschenie + { + get + { + return vodoizmeschenie; + } + + set + { + if (value > 2000 || value < 10) + { + Console.WriteLine("Невозможное водоизмещение корабля(min:10 max:2000)"); + throw new Exception(); + } + else + { + vodoizmeschenie = value; + } + } + } + public void Info() { Console.WriteLine($" пассажиров: {passangers} длина: {dlina} водоизмещение: {vodoizmeschenie}"); From 975c1453f046ea19661379bfd971d2c47043d7bd Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Thu, 3 Jan 2019 13:32:15 +0300 Subject: [PATCH 07/18] little update --- CourseApp.Tests/UnitTest2.cs | 4 ++-- CourseApp/Ship.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CourseApp.Tests/UnitTest2.cs b/CourseApp.Tests/UnitTest2.cs index b6e1dc6..51fddb2 100644 --- a/CourseApp.Tests/UnitTest2.cs +++ b/CourseApp.Tests/UnitTest2.cs @@ -82,9 +82,9 @@ public void Test11() public void Test12() { Ship admiral = new Ship(); - var resToString = admiral.ToString(); + var resPredlojenie = admiral.Predlojenie(); var dlina = admiral.Dlina; - Assert.Equal($" {dlina} ", resToString); + Assert.Equal($" {dlina} ", resPredlojenie); } } } \ No newline at end of file diff --git a/CourseApp/Ship.cs b/CourseApp/Ship.cs index 6617d89..af15333 100644 --- a/CourseApp/Ship.cs +++ b/CourseApp/Ship.cs @@ -99,11 +99,11 @@ public int Vodoizmeschenie public void Info() { Console.WriteLine($" пассажиров: {passangers} длина: {dlina} водоизмещение: {vodoizmeschenie}"); - Console.WriteLine(ToString()); + Console.WriteLine(Predlojenie()); Console.WriteLine(Ris()); } - public override string ToString() + public string Predlojenie() { return $"Корабль с длиной {dlina} метров вышел в открытое море"; } From 3616629dd6b228b21fd79b4e6df7d4da2eb4351f Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Sun, 6 Jan 2019 15:45:44 +0300 Subject: [PATCH 08/18] Completed Classes --- .gitattributes | 63 -------------------------------- CourseApp/Kater.cs | 47 ++++++++++++++++++++++++ CourseApp/Program.cs | 14 ++++++-- CourseApp/Ship.cs | 77 ++++++--------------------------------- CourseApp/Transport.cs | 82 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 151 insertions(+), 132 deletions(-) delete mode 100644 .gitattributes create mode 100644 CourseApp/Kater.cs create mode 100644 CourseApp/Transport.cs diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1ff0c42..0000000 --- a/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/CourseApp/Kater.cs b/CourseApp/Kater.cs new file mode 100644 index 0000000..b351fe9 --- /dev/null +++ b/CourseApp/Kater.cs @@ -0,0 +1,47 @@ +using System; + +namespace CourseApp +{ + public class Kater : Transport + { + public Kater() + : base() + { + Passangers = 5; + Dlina = 10; + Vodoizmeschenie = 15; + } + + public override void Info() + { + Console.WriteLine($"Катер: пассажиров:{Passangers} длина:{Dlina} водоизмещение:{Vodoizmeschenie}"); + Console.WriteLine(Predlojenie()); + Console.WriteLine(Picture()); + } + + public override string ToString() + { + return $"У катера с длиной {Dlina} громко ревет мотор"; + } + + public override string Predlojenie() + { + return $"Катер с длиной {Dlina} метров поплыл вдоль реки"; + } + + public string Picture() + { + return @" + +░░░░░░░░░░░░░█▀▀▀█████████▄▄▄░░░░░░░░░░░ +░░░░░░░░░░░▄█▀░░░░░█▀░░░░░█▀░░░░░░░░░░░░ +███████▄▄▄██▄▄▄▄░░░█░░░░░░█░░▀████▄▄▄▄▄▄ +░▄░░░▀▀▀▀▀▀▀▀███████████████▄▄▄█▄▄▄█░░██ +░▀█████████▄▄▄▄▄▄▄▄▄░░▀▀▀▀▀▀▀▀▀████████░ +░░░▀█████████████████████████▄▄▄▄▄▄▄▄▄░░ +░░░░░▀▀███████████████████████████████░░ +░░░░░░░░░░░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀░░░ +"; + } + } +} diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 0a6e5a9..0976339 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -28,8 +28,18 @@ private static void Main(string[] args) Console.WriteLine($"y({x})={Func(x, a, b)}"); } - Ship admiral = new Ship(40); - admiral.Info(); + Ship admiral = new Ship(); + Kater carter = new Kater(); + Console.WriteLine(admiral); + Console.WriteLine(carter); + Transport[] transports = new Transport[2]; + transports[0] = new Ship(); + transports[1] = new Kater(); + foreach (Transport i in transports) + { + i.Info(); + } + Console.ReadLine(); } } diff --git a/CourseApp/Ship.cs b/CourseApp/Ship.cs index af15333..3f189b0 100644 --- a/CourseApp/Ship.cs +++ b/CourseApp/Ship.cs @@ -6,16 +6,17 @@ namespace CourseApp { - public class Ship + public class Ship : Transport { private int passangers; private int dlina; private int vodoizmeschenie; public Ship() + : base() { passangers = 20; - dlina = 50; + dlina = 55; vodoizmeschenie = 100; } @@ -33,77 +34,19 @@ public Ship(int a, int b, int c) vodoizmeschenie = c; } - public int Passangers + public override void Info() { - get - { - return passangers; - } - - set - { - if (value > 250 || value < 0) - { - Console.WriteLine("Невозможное количество пассажиров(min:0 max:250)"); - throw new Exception(); - } - else - { - passangers = value; - } - } - } - - public int Dlina - { - get - { - return dlina; - } - - set - { - if (value > 1000 || value < 5) - { - Console.WriteLine("Невозможная длина корабля(min:5 max:1000)"); - throw new Exception(); - } - else - { - dlina = value; - } - } - } - - public int Vodoizmeschenie - { - get - { - return vodoizmeschenie; - } - - set - { - if (value > 2000 || value < 10) - { - Console.WriteLine("Невозможное водоизмещение корабля(min:10 max:2000)"); - throw new Exception(); - } - else - { - vodoizmeschenie = value; - } - } + Console.WriteLine($"Корабль: пассажиров:{passangers} длина:{dlina} водоизмещение:{vodoizmeschenie}"); + Console.WriteLine(Predlojenie()); + Console.WriteLine(Ris()); } - public void Info() + public override string ToString() { - Console.WriteLine($" пассажиров: {passangers} длина: {dlina} водоизмещение: {vodoizmeschenie}"); - Console.WriteLine(Predlojenie()); - Console.WriteLine(Ris()); + return $"Корабль с водоизмещением {vodoizmeschenie} громко гудит"; } - public string Predlojenie() + public override string Predlojenie() { return $"Корабль с длиной {dlina} метров вышел в открытое море"; } diff --git a/CourseApp/Transport.cs b/CourseApp/Transport.cs new file mode 100644 index 0000000..9befe7e --- /dev/null +++ b/CourseApp/Transport.cs @@ -0,0 +1,82 @@ +using System; + +namespace CourseApp +{ + public abstract class Transport + { + private int passangers; + private int dlina; + private int vodoizmeschenie; + + public Transport() + { + } + + public int Passangers + { + get + { + return passangers; + } + + set + { + if (value > 250 || value < 0) + { + Console.WriteLine("Невозможное количество пассажиров(min:0 max:250)"); + throw new Exception(); + } + else + { + passangers = value; + } + } + } + + public int Dlina + { + get + { + return dlina; + } + + set + { + if (value > 1000 || value < 5) + { + Console.WriteLine("Невозможная длина корабля(min:5 max:1000)"); + throw new Exception(); + } + else + { + dlina = value; + } + } + } + + public int Vodoizmeschenie + { + get + { + return vodoizmeschenie; + } + + set + { + if (value > 2000 || value < 10) + { + Console.WriteLine("Невозможное водоизмещение корабля(min:10 max:2000)"); + throw new Exception(); + } + else + { + vodoizmeschenie = value; + } + } + } + + public abstract void Info(); + + public abstract string Predlojenie(); + } +} From 9ef38602e43b1536f1372f40801083141179e06c Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Sun, 6 Jan 2019 16:51:22 +0300 Subject: [PATCH 09/18] Added Test3 for Kater and Test4 for Massive --- CourseApp.Tests/UnitTest2.cs | 16 ++---------- CourseApp.Tests/UnitTest3.cs | 49 ++++++++++++++++++++++++++++++++++++ CourseApp.Tests/UnitTest4.cs | 22 ++++++++++++++++ CourseApp/Ship.cs | 28 +++++++++------------ 4 files changed, 85 insertions(+), 30 deletions(-) create mode 100644 CourseApp.Tests/UnitTest3.cs create mode 100644 CourseApp.Tests/UnitTest4.cs diff --git a/CourseApp.Tests/UnitTest2.cs b/CourseApp.Tests/UnitTest2.cs index 51fddb2..65ebb5c 100644 --- a/CourseApp.Tests/UnitTest2.cs +++ b/CourseApp.Tests/UnitTest2.cs @@ -56,30 +56,18 @@ public void Test9() [Fact] public void Test10() - { - Ship admiral = new Ship(40); - var passangers = admiral.Passangers; - var dlina = admiral.Dlina; - var vodoizmeschenie = admiral.Vodoizmeschenie; - Assert.Equal(25, passangers); - Assert.Equal(40, dlina); - Assert.Equal(100, vodoizmeschenie); - } - - [Fact] - public void Test11() { Ship admiral = new Ship(); var passangers = admiral.Passangers; var dlina = admiral.Dlina; var vodoizmeschenie = admiral.Vodoizmeschenie; Assert.Equal(20, passangers); - Assert.Equal(50, dlina); + Assert.Equal(55, dlina); Assert.Equal(100, vodoizmeschenie); } [Fact] - public void Test12() + public void Test11() { Ship admiral = new Ship(); var resPredlojenie = admiral.Predlojenie(); diff --git a/CourseApp.Tests/UnitTest3.cs b/CourseApp.Tests/UnitTest3.cs new file mode 100644 index 0000000..5b99d72 --- /dev/null +++ b/CourseApp.Tests/UnitTest3.cs @@ -0,0 +1,49 @@ +using System; +using Xunit; +using CourseApp; + +namespace CourseApp.Tests +{ + public class UnitTest3 + { + [Fact] + public void Test12() + { + Kater carter = new Kater(); + var resPicture = carter.Picture(); + Assert.Equal( + @" + +░░░░░░░░░░░░░█▀▀▀█████████▄▄▄░░░░░░░░░░░ +░░░░░░░░░░░▄█▀░░░░░█▀░░░░░█▀░░░░░░░░░░░░ +███████▄▄▄██▄▄▄▄░░░█░░░░░░█░░▀████▄▄▄▄▄▄ +░▄░░░▀▀▀▀▀▀▀▀███████████████▄▄▄█▄▄▄█░░██ +░▀█████████▄▄▄▄▄▄▄▄▄░░▀▀▀▀▀▀▀▀▀████████░ +░░░▀█████████████████████████▄▄▄▄▄▄▄▄▄░░ +░░░░░▀▀███████████████████████████████░░ +░░░░░░░░░░░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀░░░ +", resPicture); + } + + [Fact] + public void Test13() + { + Kater carter = new Kater(); + var passangers = carter.Passangers; + var dlina = carter.Dlina; + var vodoizmeschenie = carter.Vodoizmeschenie; + Assert.Equal(5, passangers); + Assert.Equal(10, dlina); + Assert.Equal(15, vodoizmeschenie); + } + + [Fact] + public void Test14() + { + Kater carter = new Kater(); + var resPredlojenie = carter.Predlojenie(); + var dlina = carter.Dlina; + Assert.Equal($"Катер с длиной {dlina} метров поплыл вдоль реки", resPredlojenie); + } + } +} \ No newline at end of file diff --git a/CourseApp.Tests/UnitTest4.cs b/CourseApp.Tests/UnitTest4.cs new file mode 100644 index 0000000..84871c4 --- /dev/null +++ b/CourseApp.Tests/UnitTest4.cs @@ -0,0 +1,22 @@ +using System; +using Xunit; +using CourseApp; + +namespace CourseApp.Tests +{ + public class UnitTest4 + { + [Fact] + public void Test15() + { + Ship admiral = new Ship(); + Kater carter = new Kater(); + var resPredlojenie = admiral.Predlojenie(); + var dlina = admiral.Dlina; + var resPredlojenies = carter.Predlojenie(); + var dlinas = carter.Dlina; + Assert.Equal($"Катер с длиной {dlinas} метров поплыл вдоль реки", resPredlojenies); + Assert.Equal($"Корабль с длиной {dlina} метров вышел в открытое море", resPredlojenie); + } + } +} \ No newline at end of file diff --git a/CourseApp/Ship.cs b/CourseApp/Ship.cs index 3f189b0..0f31827 100644 --- a/CourseApp/Ship.cs +++ b/CourseApp/Ship.cs @@ -8,47 +8,43 @@ namespace CourseApp { public class Ship : Transport { - private int passangers; - private int dlina; - private int vodoizmeschenie; - public Ship() : base() { - passangers = 20; - dlina = 55; - vodoizmeschenie = 100; + Passangers = 20; + Dlina = 55; + Vodoizmeschenie = 100; } public Ship(int b) { - passangers = 25; - dlina = b; - vodoizmeschenie = 100; + Passangers = 25; + Dlina = b; + Vodoizmeschenie = 100; } public Ship(int a, int b, int c) { - passangers = a; - dlina = b; - vodoizmeschenie = c; + Passangers = a; + Dlina = b; + Vodoizmeschenie = c; } public override void Info() { - Console.WriteLine($"Корабль: пассажиров:{passangers} длина:{dlina} водоизмещение:{vodoizmeschenie}"); + Console.WriteLine($"Корабль: пассажиров:{Passangers} длина:{Dlina} водоизмещение:{Vodoizmeschenie}"); Console.WriteLine(Predlojenie()); Console.WriteLine(Ris()); } public override string ToString() { - return $"Корабль с водоизмещением {vodoizmeschenie} громко гудит"; + return $"Корабль с длиной {Dlina} громко гудит"; } public override string Predlojenie() { - return $"Корабль с длиной {dlina} метров вышел в открытое море"; + return $"Корабль с длиной {Dlina} метров вышел в открытое море"; } public string Ris() From 6cf92495c00c4eaddef9bcdc60b2a1e80e2184fc Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Sun, 13 Jan 2019 15:03:56 +0300 Subject: [PATCH 10/18] Fixed classes and tests --- CourseApp.Tests/UnitTest2.cs | 16 +++++----------- CourseApp.Tests/UnitTest3.cs | 16 +++++----------- CourseApp.Tests/UnitTest4.cs | 22 ---------------------- CourseApp/Kater.cs | 27 +++++++++++++++++++++++++-- CourseApp/Ship.cs | 35 +++++++++++++++++++++++++++++------ CourseApp/Transport.cs | 26 -------------------------- 6 files changed, 64 insertions(+), 78 deletions(-) delete mode 100644 CourseApp.Tests/UnitTest4.cs diff --git a/CourseApp.Tests/UnitTest2.cs b/CourseApp.Tests/UnitTest2.cs index 65ebb5c..e5285bf 100644 --- a/CourseApp.Tests/UnitTest2.cs +++ b/CourseApp.Tests/UnitTest2.cs @@ -10,7 +10,6 @@ public class UnitTest2 public void Test9() { Ship admiral = new Ship(); - var resRis = admiral.Ris(); Assert.Equal( @"_ _____________________ @@ -51,28 +50,23 @@ public void Test9() ___________________________________ _________________________________ ___________ -", resRis); +", admiral.Ris()); } [Fact] public void Test10() { Ship admiral = new Ship(); - var passangers = admiral.Passangers; - var dlina = admiral.Dlina; - var vodoizmeschenie = admiral.Vodoizmeschenie; - Assert.Equal(20, passangers); - Assert.Equal(55, dlina); - Assert.Equal(100, vodoizmeschenie); + Assert.Equal(20, admiral.Passangers); + Assert.Equal(55, admiral.Dlina); + Assert.Equal(100, admiral.Vodoizmeschenie); } [Fact] public void Test11() { Ship admiral = new Ship(); - var resPredlojenie = admiral.Predlojenie(); - var dlina = admiral.Dlina; - Assert.Equal($" {dlina} ", resPredlojenie); + Assert.Equal($" {admiral.Dlina} ", admiral.Predlojenie()); } } } \ No newline at end of file diff --git a/CourseApp.Tests/UnitTest3.cs b/CourseApp.Tests/UnitTest3.cs index 5b99d72..f177564 100644 --- a/CourseApp.Tests/UnitTest3.cs +++ b/CourseApp.Tests/UnitTest3.cs @@ -10,7 +10,6 @@ public class UnitTest3 public void Test12() { Kater carter = new Kater(); - var resPicture = carter.Picture(); Assert.Equal( @" @@ -22,28 +21,23 @@ public void Test12() ░░░▀█████████████████████████▄▄▄▄▄▄▄▄▄░░ ░░░░░▀▀███████████████████████████████░░ ░░░░░░░░░░░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀░░░ -", resPicture); +", carter.Picture()); } [Fact] public void Test13() { Kater carter = new Kater(); - var passangers = carter.Passangers; - var dlina = carter.Dlina; - var vodoizmeschenie = carter.Vodoizmeschenie; - Assert.Equal(5, passangers); - Assert.Equal(10, dlina); - Assert.Equal(15, vodoizmeschenie); + Assert.Equal(5, carter.Passangers); + Assert.Equal(10, carter.Dlina); + Assert.Equal(50, carter.Maxspeed); } [Fact] public void Test14() { Kater carter = new Kater(); - var resPredlojenie = carter.Predlojenie(); - var dlina = carter.Dlina; - Assert.Equal($"Катер с длиной {dlina} метров поплыл вдоль реки", resPredlojenie); + Assert.Equal($"Катер с длиной {carter.Dlina} метров поплыл вдоль реки", carter.Predlojenie()); } } } \ No newline at end of file diff --git a/CourseApp.Tests/UnitTest4.cs b/CourseApp.Tests/UnitTest4.cs deleted file mode 100644 index 84871c4..0000000 --- a/CourseApp.Tests/UnitTest4.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using Xunit; -using CourseApp; - -namespace CourseApp.Tests -{ - public class UnitTest4 - { - [Fact] - public void Test15() - { - Ship admiral = new Ship(); - Kater carter = new Kater(); - var resPredlojenie = admiral.Predlojenie(); - var dlina = admiral.Dlina; - var resPredlojenies = carter.Predlojenie(); - var dlinas = carter.Dlina; - Assert.Equal($"Катер с длиной {dlinas} метров поплыл вдоль реки", resPredlojenies); - Assert.Equal($"Корабль с длиной {dlina} метров вышел в открытое море", resPredlojenie); - } - } -} \ No newline at end of file diff --git a/CourseApp/Kater.cs b/CourseApp/Kater.cs index b351fe9..17c9e72 100644 --- a/CourseApp/Kater.cs +++ b/CourseApp/Kater.cs @@ -4,17 +4,40 @@ namespace CourseApp { public class Kater : Transport { + private int maxspeed; + public Kater() : base() { Passangers = 5; Dlina = 10; - Vodoizmeschenie = 15; + Maxspeed = 50; + } + + public int Maxspeed + { + get + { + return maxspeed; + } + + set + { + if (value > 400 || value < 1) + { + Console.WriteLine("Невозможное водоизмещение корабля(min:10 max:2000)"); + throw new Exception(); + } + else + { + maxspeed = value; + } + } } public override void Info() { - Console.WriteLine($"Катер: пассажиров:{Passangers} длина:{Dlina} водоизмещение:{Vodoizmeschenie}"); + Console.WriteLine($"Катер: пассажиров:{Passangers} длина:{Dlina}, максимальная скорость:{Maxspeed}"); Console.WriteLine(Predlojenie()); Console.WriteLine(Picture()); } diff --git a/CourseApp/Ship.cs b/CourseApp/Ship.cs index 0f31827..0707f01 100644 --- a/CourseApp/Ship.cs +++ b/CourseApp/Ship.cs @@ -8,6 +8,8 @@ namespace CourseApp { public class Ship : Transport { + private int vodoizmeschenie; + public Ship() : base() { @@ -16,18 +18,39 @@ public Ship() Vodoizmeschenie = 100; } - public Ship(int b) + public Ship(int dlina) { Passangers = 25; - Dlina = b; + Dlina = dlina; Vodoizmeschenie = 100; } - public Ship(int a, int b, int c) + public Ship(int passangers, int dlina, int vodoizmeschenie) { - Passangers = a; - Dlina = b; - Vodoizmeschenie = c; + Passangers = passangers; + Dlina = dlina; + Vodoizmeschenie = vodoizmeschenie; + } + + public int Vodoizmeschenie + { + get + { + return vodoizmeschenie; + } + + set + { + if (value > 2000 || value < 10) + { + Console.WriteLine("Невозможное водоизмещение корабля(min:10 max:2000)"); + throw new Exception(); + } + else + { + vodoizmeschenie = value; + } + } } public override void Info() diff --git a/CourseApp/Transport.cs b/CourseApp/Transport.cs index 9befe7e..b23e21b 100644 --- a/CourseApp/Transport.cs +++ b/CourseApp/Transport.cs @@ -6,11 +6,6 @@ public abstract class Transport { private int passangers; private int dlina; - private int vodoizmeschenie; - - public Transport() - { - } public int Passangers { @@ -54,27 +49,6 @@ public int Dlina } } - public int Vodoizmeschenie - { - get - { - return vodoizmeschenie; - } - - set - { - if (value > 2000 || value < 10) - { - Console.WriteLine("Невозможное водоизмещение корабля(min:10 max:2000)"); - throw new Exception(); - } - else - { - vodoizmeschenie = value; - } - } - } - public abstract void Info(); public abstract string Predlojenie(); From 1c3e5f267109a4a6dd5c7732a845ff6f2b2e912c Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Sun, 13 Jan 2019 20:52:16 +0300 Subject: [PATCH 11/18] Renamed Tests --- CourseApp.Tests/UnitTest2.cs | 6 +++--- CourseApp.Tests/UnitTest3.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CourseApp.Tests/UnitTest2.cs b/CourseApp.Tests/UnitTest2.cs index e5285bf..de536f2 100644 --- a/CourseApp.Tests/UnitTest2.cs +++ b/CourseApp.Tests/UnitTest2.cs @@ -7,7 +7,7 @@ namespace CourseApp.Tests public class UnitTest2 { [Fact] - public void Test9() + public void TestofRis() { Ship admiral = new Ship(); Assert.Equal( @@ -54,7 +54,7 @@ public void Test9() } [Fact] - public void Test10() + public void Testofznacheniya() { Ship admiral = new Ship(); Assert.Equal(20, admiral.Passangers); @@ -63,7 +63,7 @@ public void Test10() } [Fact] - public void Test11() + public void Testofpredlojenia() { Ship admiral = new Ship(); Assert.Equal($" {admiral.Dlina} ", admiral.Predlojenie()); diff --git a/CourseApp.Tests/UnitTest3.cs b/CourseApp.Tests/UnitTest3.cs index f177564..74cefb0 100644 --- a/CourseApp.Tests/UnitTest3.cs +++ b/CourseApp.Tests/UnitTest3.cs @@ -7,7 +7,7 @@ namespace CourseApp.Tests public class UnitTest3 { [Fact] - public void Test12() + public void TestofPicture() { Kater carter = new Kater(); Assert.Equal( @@ -25,7 +25,7 @@ public void Test12() } [Fact] - public void Test13() + public void Testofznacheniya() { Kater carter = new Kater(); Assert.Equal(5, carter.Passangers); @@ -34,7 +34,7 @@ public void Test13() } [Fact] - public void Test14() + public void Testofpredlojeniya() { Kater carter = new Kater(); Assert.Equal($"Катер с длиной {carter.Dlina} метров поплыл вдоль реки", carter.Predlojenie()); From 672e0df8ee4b6763fb93f1563553f2549610134e Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Sun, 13 Jan 2019 20:55:49 +0300 Subject: [PATCH 12/18] Renamed Tests v1.1 --- CourseApp.Tests/{UnitTest1.cs => TestofFunction.cs} | 2 +- CourseApp.Tests/{UnitTest3.cs => TestofKater.cs} | 2 +- CourseApp.Tests/{UnitTest2.cs => TestofShip.cs} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename CourseApp.Tests/{UnitTest1.cs => TestofFunction.cs} (97%) rename CourseApp.Tests/{UnitTest3.cs => TestofKater.cs} (98%) rename CourseApp.Tests/{UnitTest2.cs => TestofShip.cs} (98%) diff --git a/CourseApp.Tests/UnitTest1.cs b/CourseApp.Tests/TestofFunction.cs similarity index 97% rename from CourseApp.Tests/UnitTest1.cs rename to CourseApp.Tests/TestofFunction.cs index 5ceb1d1..de395e1 100644 --- a/CourseApp.Tests/UnitTest1.cs +++ b/CourseApp.Tests/TestofFunction.cs @@ -4,7 +4,7 @@ namespace CourseApp.Tests { - public class UnitTest1 + public class TestofFunction { [Fact] public void Test1() diff --git a/CourseApp.Tests/UnitTest3.cs b/CourseApp.Tests/TestofKater.cs similarity index 98% rename from CourseApp.Tests/UnitTest3.cs rename to CourseApp.Tests/TestofKater.cs index 74cefb0..d271cf7 100644 --- a/CourseApp.Tests/UnitTest3.cs +++ b/CourseApp.Tests/TestofKater.cs @@ -4,7 +4,7 @@ namespace CourseApp.Tests { - public class UnitTest3 + public class TestofKater { [Fact] public void TestofPicture() diff --git a/CourseApp.Tests/UnitTest2.cs b/CourseApp.Tests/TestofShip.cs similarity index 98% rename from CourseApp.Tests/UnitTest2.cs rename to CourseApp.Tests/TestofShip.cs index de536f2..7140936 100644 --- a/CourseApp.Tests/UnitTest2.cs +++ b/CourseApp.Tests/TestofShip.cs @@ -4,7 +4,7 @@ namespace CourseApp.Tests { - public class UnitTest2 + public class TestofShip { [Fact] public void TestofRis() From e8242b1c2f6b207e9a7f1f45ecba9f935b42a3df Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Tue, 9 Apr 2019 17:35:26 +0300 Subject: [PATCH 13/18] Added Interfaces --- CourseApp/ISwim.cs | 9 +++++++++ CourseApp/Kater.cs | 8 +++++++- CourseApp/Program.cs | 14 ++++++++++++++ CourseApp/Ship.cs | 21 ++++++++++++++++++++- 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 CourseApp/ISwim.cs diff --git a/CourseApp/ISwim.cs b/CourseApp/ISwim.cs new file mode 100644 index 0000000..359f0e7 --- /dev/null +++ b/CourseApp/ISwim.cs @@ -0,0 +1,9 @@ +using System; + +namespace CourseApp +{ + public interface ISwim + { + string Swim(object o); + } +} diff --git a/CourseApp/Kater.cs b/CourseApp/Kater.cs index 17c9e72..2f40dcb 100644 --- a/CourseApp/Kater.cs +++ b/CourseApp/Kater.cs @@ -2,7 +2,7 @@ namespace CourseApp { - public class Kater : Transport + public class Kater : Transport, ISwim { private int maxspeed; @@ -35,6 +35,12 @@ public int Maxspeed } } + public string Swim(object o) + { + Kater c = o as Kater; + return $"При создании катера учитывалось,что его длина будет {c.Dlina}"; + } + public override void Info() { Console.WriteLine($"Катер: пассажиров:{Passangers} длина:{Dlina}, максимальная скорость:{Maxspeed}"); diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 0976339..7be3760 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -29,6 +29,8 @@ private static void Main(string[] args) } Ship admiral = new Ship(); + Ship lucky = new Ship(90); + Ship duty = new Ship(150, 75, 300); Kater carter = new Kater(); Console.WriteLine(admiral); Console.WriteLine(carter); @@ -40,6 +42,18 @@ private static void Main(string[] args) i.Info(); } + Console.WriteLine(admiral.Swim(admiral)); + Console.WriteLine(lucky.Swim(lucky)); + Console.WriteLine(duty.Swim(duty)); + + Ship[] arrayOfShip = new Ship[] {admiral, lucky, duty }; + + Array.Sort(arrayOfShip); + foreach (Ship o in arrayOfShip) + { + Console.WriteLine("{0} - {1}", o.Passangers, o.Dlina, o.Vodoizmeschenie); + } + Console.ReadLine(); } } diff --git a/CourseApp/Ship.cs b/CourseApp/Ship.cs index 0707f01..5dd9977 100644 --- a/CourseApp/Ship.cs +++ b/CourseApp/Ship.cs @@ -6,7 +6,7 @@ namespace CourseApp { - public class Ship : Transport + public class Ship : Transport, ISwim, IComparable { private int vodoizmeschenie; @@ -53,6 +53,25 @@ public int Vodoizmeschenie } } + public string Swim(object o) + { + Ship c = o as Ship; + return $"Корабль с длиной {c.Dlina} остановился у причала"; + } + + public int CompareTo(object o) + { + Ship p = o as Ship; + if (p != null) + { + return this.Dlina.CompareTo(p.Dlina); + } + else + { + throw new Exception("Невозможно сравнить"); + } + } + public override void Info() { Console.WriteLine($"Корабль: пассажиров:{Passangers} длина:{Dlina} водоизмещение:{Vodoizmeschenie}"); From 2023daded26e45e674b9b8feaa11b2f780e26689 Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Thu, 11 Apr 2019 17:17:34 +0300 Subject: [PATCH 14/18] Modified Interfaces --- CourseApp/Kater.cs | 8 ++++---- CourseApp/Program.cs | 21 +++++++++++++++++---- CourseApp/Ship.cs | 16 ++++++++-------- CourseApp/Transport.cs | 15 +++++---------- 4 files changed, 34 insertions(+), 26 deletions(-) diff --git a/CourseApp/Kater.cs b/CourseApp/Kater.cs index 2f40dcb..32d5776 100644 --- a/CourseApp/Kater.cs +++ b/CourseApp/Kater.cs @@ -9,7 +9,7 @@ public class Kater : Transport, ISwim public Kater() : base() { - Passangers = 5; + Name = "Carter"; Dlina = 10; Maxspeed = 50; } @@ -38,12 +38,12 @@ public int Maxspeed public string Swim(object o) { Kater c = o as Kater; - return $"При создании катера учитывалось,что его длина будет {c.Dlina}"; + return $"{Name} плывет по течению"; } public override void Info() { - Console.WriteLine($"Катер: пассажиров:{Passangers} длина:{Dlina}, максимальная скорость:{Maxspeed}"); + Console.WriteLine($"Катер: Имя:{Name} длина:{Dlina}, максимальная скорость:{Maxspeed}"); Console.WriteLine(Predlojenie()); Console.WriteLine(Picture()); } @@ -55,7 +55,7 @@ public override string ToString() public override string Predlojenie() { - return $"Катер с длиной {Dlina} метров поплыл вдоль реки"; + return $"Катер {Name} поплыл вдоль реки"; } public string Picture() diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 7be3760..cc7d4cd 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -30,13 +30,26 @@ private static void Main(string[] args) Ship admiral = new Ship(); Ship lucky = new Ship(90); - Ship duty = new Ship(150, 75, 300); - Kater carter = new Kater(); + Ship duty = new Ship("Duty", 75, 300); + + admiral.Info(); + lucky.Info(); + duty.Info(); + + admiral.Dlina = 200; + Console.WriteLine($"Длина Адмирала - {admiral.Dlina} метров"); Console.WriteLine(admiral); + admiral.Info(); + + Kater carter = new Kater(); + carter.Info(); Console.WriteLine(carter); + Transport[] transports = new Transport[2]; transports[0] = new Ship(); transports[1] = new Kater(); + + Console.WriteLine("\nинфо в массиве\n"); foreach (Transport i in transports) { i.Info(); @@ -44,14 +57,14 @@ private static void Main(string[] args) Console.WriteLine(admiral.Swim(admiral)); Console.WriteLine(lucky.Swim(lucky)); - Console.WriteLine(duty.Swim(duty)); + Console.WriteLine(carter.Swim(carter)); Ship[] arrayOfShip = new Ship[] {admiral, lucky, duty }; Array.Sort(arrayOfShip); foreach (Ship o in arrayOfShip) { - Console.WriteLine("{0} - {1}", o.Passangers, o.Dlina, o.Vodoizmeschenie); + Console.WriteLine("{0} - {1}", o.Name, o.Dlina, o.Vodoizmeschenie); } Console.ReadLine(); diff --git a/CourseApp/Ship.cs b/CourseApp/Ship.cs index 5dd9977..a3a16cb 100644 --- a/CourseApp/Ship.cs +++ b/CourseApp/Ship.cs @@ -13,21 +13,21 @@ public class Ship : Transport, ISwim, IComparable public Ship() : base() { - Passangers = 20; + Name = "Admiral"; Dlina = 55; Vodoizmeschenie = 100; } public Ship(int dlina) { - Passangers = 25; + Name = "Lucky"; Dlina = dlina; Vodoizmeschenie = 100; } - public Ship(int passangers, int dlina, int vodoizmeschenie) + public Ship(string name, int dlina, int vodoizmeschenie) { - Passangers = passangers; + Name = name; Dlina = dlina; Vodoizmeschenie = vodoizmeschenie; } @@ -56,7 +56,7 @@ public int Vodoizmeschenie public string Swim(object o) { Ship c = o as Ship; - return $"Корабль с длиной {c.Dlina} остановился у причала"; + return $"Корабль {c.Name} остановился у причала"; } public int CompareTo(object o) @@ -64,7 +64,7 @@ public int CompareTo(object o) Ship p = o as Ship; if (p != null) { - return this.Dlina.CompareTo(p.Dlina); + return this.Name.CompareTo(p.Name); } else { @@ -74,7 +74,7 @@ public int CompareTo(object o) public override void Info() { - Console.WriteLine($"Корабль: пассажиров:{Passangers} длина:{Dlina} водоизмещение:{Vodoizmeschenie}"); + Console.WriteLine($"Корабль: Имя:{Name} длина:{Dlina} водоизмещение:{Vodoizmeschenie}"); Console.WriteLine(Predlojenie()); Console.WriteLine(Ris()); } @@ -86,7 +86,7 @@ public override string ToString() public override string Predlojenie() { - return $"Корабль с длиной {Dlina} метров вышел в открытое море"; + return $"Корабль {Name} вышел в открытое море"; } public string Ris() diff --git a/CourseApp/Transport.cs b/CourseApp/Transport.cs index b23e21b..e528b1b 100644 --- a/CourseApp/Transport.cs +++ b/CourseApp/Transport.cs @@ -4,26 +4,21 @@ namespace CourseApp { public abstract class Transport { - private int passangers; + private string name; private int dlina; - public int Passangers + public string Name { get { - return passangers; + return name; } set { - if (value > 250 || value < 0) + if (value != null) { - Console.WriteLine("Невозможное количество пассажиров(min:0 max:250)"); - throw new Exception(); - } - else - { - passangers = value; + this.name = value; } } } From f5100da25bacda7d47d15019e517daec3126c152 Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Thu, 11 Apr 2019 17:26:51 +0300 Subject: [PATCH 15/18] UPD 1 --- CourseApp/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index cc7d4cd..f79a8d3 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -64,7 +64,7 @@ private static void Main(string[] args) Array.Sort(arrayOfShip); foreach (Ship o in arrayOfShip) { - Console.WriteLine("{0} - {1}", o.Name, o.Dlina, o.Vodoizmeschenie); + Console.WriteLine("{0} - {1} - {2}", o.Name, o.Dlina, o.Vodoizmeschenie); } Console.ReadLine(); From 0042e9374e051248aa2340e7ca0183c1a076408a Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Sun, 14 Apr 2019 13:07:33 +0300 Subject: [PATCH 16/18] Added Tests for interfaces --- CourseApp.Tests/TestofIComparable.cs | 25 +++++++++++++++++++++++++ CourseApp.Tests/TestofKater.cs | 12 ++++++++++-- CourseApp.Tests/TestofShip.cs | 20 ++++++++++++++++++-- 3 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 CourseApp.Tests/TestofIComparable.cs diff --git a/CourseApp.Tests/TestofIComparable.cs b/CourseApp.Tests/TestofIComparable.cs new file mode 100644 index 0000000..fda59f5 --- /dev/null +++ b/CourseApp.Tests/TestofIComparable.cs @@ -0,0 +1,25 @@ +using System; +using Xunit; +using CourseApp; + +namespace CourseApp.Tests +{ + public class TestofIComparable + { + [Fact] + public void Testcomparable() + { + string icomparable = @"Admiral - 200 - 100 +Duty - 75 - 300 +Lucky - 90 - 100"; + Ship admiral = new Ship(); + Ship lucky = new Ship(90); + Ship duty = new Ship("Duty", 75, 300); + Ship[] araryOfShip = new Ship[] { admiral, lucky, duty }; + Assert.Equal( + @"Admiral - 200 - 100 +Duty - 75 - 300 +Lucky - 90 - 100", icomparable); + } + } +} \ No newline at end of file diff --git a/CourseApp.Tests/TestofKater.cs b/CourseApp.Tests/TestofKater.cs index d271cf7..0768e54 100644 --- a/CourseApp.Tests/TestofKater.cs +++ b/CourseApp.Tests/TestofKater.cs @@ -28,7 +28,7 @@ public void TestofPicture() public void Testofznacheniya() { Kater carter = new Kater(); - Assert.Equal(5, carter.Passangers); + Assert.Equal("Carter", carter.Name); Assert.Equal(10, carter.Dlina); Assert.Equal(50, carter.Maxspeed); } @@ -37,7 +37,15 @@ public void Testofznacheniya() public void Testofpredlojeniya() { Kater carter = new Kater(); - Assert.Equal($"Катер с длиной {carter.Dlina} метров поплыл вдоль реки", carter.Predlojenie()); + Assert.Equal($"Катер {carter.Name} поплыл вдоль реки", carter.Predlojenie()); + } + + [Fact] + public void CarterISwim() + { + Kater carter = new Kater(); + string iswim = carter.Swim(carter); + Assert.Equal($"{carter.Name} плывет по течению", iswim); } } } \ No newline at end of file diff --git a/CourseApp.Tests/TestofShip.cs b/CourseApp.Tests/TestofShip.cs index 7140936..a9bde7f 100644 --- a/CourseApp.Tests/TestofShip.cs +++ b/CourseApp.Tests/TestofShip.cs @@ -57,7 +57,7 @@ public void TestofRis() public void Testofznacheniya() { Ship admiral = new Ship(); - Assert.Equal(20, admiral.Passangers); + Assert.Equal("Admiral", admiral.Name); Assert.Equal(55, admiral.Dlina); Assert.Equal(100, admiral.Vodoizmeschenie); } @@ -66,7 +66,23 @@ public void Testofznacheniya() public void Testofpredlojenia() { Ship admiral = new Ship(); - Assert.Equal($" {admiral.Dlina} ", admiral.Predlojenie()); + Assert.Equal($" {admiral.Name} ", admiral.Predlojenie()); + } + + [Fact] + public void AdmiralISwim() + { + Ship admiral = new Ship(); + string iswim = admiral.Swim(admiral); + Assert.Equal($" Admiral ", iswim); + } + + [Fact] + public void LuckyISwim() + { + Ship lucky = new Ship(90); + string iswim = lucky.Swim(lucky); + Assert.Equal($" Lucky ", iswim); } } } \ No newline at end of file From ac7a1dfc080d50187bfb68c3d6177eb1adf1986d Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Sun, 14 Apr 2019 13:52:51 +0300 Subject: [PATCH 17/18] Added Date task and tests --- CourseApp.Tests/TestofDate.cs | 30 ++++++++++++++++++++++++++++++ CourseApp/Date.cs | 26 ++++++++++++++++++++++++++ CourseApp/Program.cs | 5 +++++ 3 files changed, 61 insertions(+) create mode 100644 CourseApp.Tests/TestofDate.cs create mode 100644 CourseApp/Date.cs diff --git a/CourseApp.Tests/TestofDate.cs b/CourseApp.Tests/TestofDate.cs new file mode 100644 index 0000000..8036ef9 --- /dev/null +++ b/CourseApp.Tests/TestofDate.cs @@ -0,0 +1,30 @@ +using System; +using Xunit; +using CourseApp; + +namespace CourseApp.Tests +{ + public class TestofDate + { + [Fact] + public void EqualDates() + { + string schetvozrasta = Date.SchetVozrasta(new DateTime(1999, 9, 30), new DateTime(1999, 9, 30)); + Assert.Equal(" : 0 , 0 , 0 ", schetvozrasta); + } + + [Fact] + public void BirthdayBeforeToday() + { + string schetvozrasta = Date.SchetVozrasta(new DateTime(1999, 9, 30), new DateTime(2019, 4, 14)); + Assert.Equal(" : 19 , 6 , 14 ", schetvozrasta); + } + + [Fact] + public void BirthdayAfterToday() + { + string schetvozrasta = Date.SchetVozrasta(new DateTime(2029, 9, 30), new DateTime(2019, 4, 14)); + Assert.Equal(" !", schetvozrasta); + } + } +} \ No newline at end of file diff --git a/CourseApp/Date.cs b/CourseApp/Date.cs new file mode 100644 index 0000000..95c54b0 --- /dev/null +++ b/CourseApp/Date.cs @@ -0,0 +1,26 @@ +using System; + +namespace CourseApp +{ + public class Date + { + public static string SchetVozrasta(DateTime bornday, DateTime today) + { + DateTime todaydate = today; + if (today.Day == bornday.Day) + { + return "Ваш возраст: 0 лет, 0 месяцев, 0 дней"; + } + + if (today < bornday) + { + return $"Еще не родился!"; + } + + todaydate = todaydate.AddYears(-bornday.Year); + todaydate = todaydate.AddMonths(-bornday.Month); + todaydate = todaydate.AddDays(-bornday.Day); + return $"Ваш возраст: {todaydate.Year} лет, {todaydate.Month} месяцев, {todaydate.Day} дней"; + } + } +} diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index f79a8d3..c7e221b 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -67,6 +67,11 @@ private static void Main(string[] args) Console.WriteLine("{0} - {1} - {2}", o.Name, o.Dlina, o.Vodoizmeschenie); } + Console.WriteLine("\nЗадача на возраст \n"); + DateTime bornday = new DateTime(1999, 9, 30); + DateTime today = new DateTime(2019, 4, 14); + Console.WriteLine(Date.SchetVozrasta(bornday, today)); + Console.ReadLine(); } } From 4ec8a16562237e1b470a1a71cb0e4884dfed65ee Mon Sep 17 00:00:00 2001 From: Oleg Lifanov Date: Mon, 10 Jun 2019 22:56:36 +0300 Subject: [PATCH 18/18] Added SQL --- SQL/SQL.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 SQL/SQL.txt diff --git a/SQL/SQL.txt b/SQL/SQL.txt new file mode 100644 index 0000000..3901fc1 --- /dev/null +++ b/SQL/SQL.txt @@ -0,0 +1,17 @@ +1)select title from Movie where director ="Steven Spielberg"; + +2)select distinct year from Rating, Movie where stars >= 4 and Movie.mID=Rating.mID order by year; + +3)select title from Movie where Movie.mID not in (select Rating.mID from Rating); + +4)select name from Reviewer, Rating where Reviewer.rID=Rating.rID and Rating.ratingDate is null; + +5)select distinct Reviewer.name, Movie.title, Rating.stars, Rating.ratingDate from (Movie join Rating) join Reviewer on Rating.mID=Movie.mID and Rating.rID=Reviewer.rID order by Reviewer.name, Movie.title, Rating.stars; + +6)select distinct Reviewer.name, Movie.title from Movie, Reviewer, Rating R1,Rating R2 where R1.rID=Reviewer.rID and Movie.mID=R1.mID and R1.stars>R2.stars and R1.ratingDate > R2.ratingDate and (R1.rID=R2.rId and R1.ratingDate <> R2.ratingDate) and R1.ratingDate is not null and R2.ratingDate is not null and (R1.mID = R2.mId and R1.ratingDate <>R2.ratingDate); + +7)select title, max(stars) from Rating, Movie where Rating.mID = Movie.mID group by Rating.mID; + +8)select distinct title, avg(stars) from Movie, Rating where Movie.mID = Rating.mID group by title order by avg(stars) desc; + +9)select distinct name from Rating, Reviewer where Rating.rID = Reviewer.rID and stars >= 3; \ No newline at end of file