diff --git a/CourseApp.Tests/CourseApp.Tests.csproj b/CourseApp.Tests/CourseApp.Tests.csproj
new file mode 100644
index 0000000..a6e2699
--- /dev/null
+++ b/CourseApp.Tests/CourseApp.Tests.csproj
@@ -0,0 +1,30 @@
+
+
+
+ netcoreapp2.1
+ True
+ 1573,1591,1701;1702;1705
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ../stylecop/stylecop.ruleset
+ true
+
+
+
+
+
+
+
diff --git a/CourseApp.Tests/DateTest.cs b/CourseApp.Tests/DateTest.cs
new file mode 100644
index 0000000..90eb749
--- /dev/null
+++ b/CourseApp.Tests/DateTest.cs
@@ -0,0 +1,33 @@
+using System;
+using Xunit;
+using CourseApp;
+
+namespace CourseApp.Tests
+{
+ public class DateTest
+ {
+ [Fact]
+ public void Test1()
+ {
+ DateTime dr = new DateTime(1990, 9, 17);
+ var time = Date.DateB(dr);
+ Assert.Equal("Год: 28 Месяц: 05 День: 20", Date.DateB(dr));
+ }
+
+ [Fact]
+ public void Test2()
+ {
+ DateTime dr = new DateTime(2010, 2, 2);
+ var time = Date.DateB(dr);
+ Assert.Equal("Год: 09 Месяц: 01 День: 04", Date.DateB(dr));
+ }
+
+ [Fact]
+ public void Test3()
+ {
+ DateTime dr = new DateTime(11, 11, 11);
+ var time = Date.DateB(dr);
+ Assert.Equal("Год: 07 Месяц: 03 День: 26", Date.DateB(dr));
+ }
+ }
+ }
\ No newline at end of file
diff --git a/CourseApp.Tests/DemoTest.cs b/CourseApp.Tests/DemoTest.cs
new file mode 100644
index 0000000..09e415e
--- /dev/null
+++ b/CourseApp.Tests/DemoTest.cs
@@ -0,0 +1,14 @@
+using System;
+using Xunit;
+
+namespace CourseApp.Tests
+{
+ public class DemoTest
+ {
+ [Fact]
+ public void Test1()
+ {
+ Assert.True(true);
+ }
+ }
+}
diff --git a/CourseApp.Tests/UnitTest1.cs b/CourseApp.Tests/UnitTest1.cs
new file mode 100644
index 0000000..84b1888
--- /dev/null
+++ b/CourseApp.Tests/UnitTest1.cs
@@ -0,0 +1,58 @@
+using System;
+using Xunit;
+using CourseApp;
+
+namespace CourseApp.Tests
+{
+ public class UnitTest1
+ {
+
+ [Fact]
+ public void Test1()
+ {
+ var res = Program.Fan(0.7,1.2,0.48);
+ Assert.Equal(0.326, res, 3);
+ }
+
+ [Fact]
+ public void Test2()
+ {
+ var res = Program.Fan(1.0,1.2,0.48);
+ Assert.Equal(0.584, res, 3);
+ }
+
+ [Fact]
+ public void Test3()
+ {
+ var res = Program.Fan(1.3,1.2,0.48);
+ Assert.Equal(0.968, res, 3);
+ }
+
+ [Fact]
+ public void Test4()
+ {
+ var res = Program.Fan(1.6,1.2,0.48);
+ Assert.Equal(Double.NaN, res, 3);
+ }
+
+ [Fact]
+ public void Test5()
+ {
+ var res = Program.Fan(1.9,1.2,0.48);
+ Assert.Equal(Double.NaN, res, 3);
+ }
+
+ double[] xx = {0.25, 0.36, 0.56, 0.94, 1.28};
+
+ [Fact]
+ public void Test6()
+ {
+ double[] o = new double[5] {0.082,0.122,0.229,0.528,0.930};
+ foreach (int i in xx)
+ {
+ var res = Program.Fan(xx[i],1.2,0.48);
+ Assert.Equal(o[i], res, 3);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp.Tests/UnitTest2.cs b/CourseApp.Tests/UnitTest2.cs
new file mode 100644
index 0000000..fa50a33
--- /dev/null
+++ b/CourseApp.Tests/UnitTest2.cs
@@ -0,0 +1,82 @@
+using System;
+using Xunit;
+using CourseApp;
+using System.Collections.Generic;
+using System.Collections;
+
+namespace CourseApp.Tests
+{
+ public class UnitTest2
+ {
+ [Fact]
+ public void Test1()
+ {
+ var krosh = new InfoRabbit();
+ var N ="momo";
+ krosh.RabbitInfo(N);
+ Assert.Equal("momo",N);
+ }
+ [Fact]
+ public void Test2()
+ {
+ var krosh = new InfoRabbit();
+ var N ="momo";
+ var P1 = "mu";
+ var P2 = "nu";
+ krosh.RabbitInfo(N);
+ Assert.Equal("momo",N);
+ Assert.Equal("mu",P1);
+ Assert.Equal("nu",P2);
+ }
+ [Fact]
+ public void Test3()
+ {
+ var krosh = new InfoRabbit();
+ var N ="momo";
+ var P1 = "mu";
+ var P2 = "nu";
+ List ch=new List {"Mura","Gura","Fedya"};
+ krosh.RabbitInfo(N,P1,P2,ch);
+ Assert.Equal("momo",N);
+ Assert.Equal("mu",P1);
+ Assert.Equal("nu",P2);
+ Assert.Equal("Mura",ch[0]);
+ Assert.Equal("Gura",ch[1]);
+ Assert.Equal("Fedya",ch[2]);
+ }
+ [Fact]
+ public void Test4()
+ {
+ Menu ferma = new Menu();
+ ferma.Name = "Boo";
+ Assert.Equal("Boo",ferma.Name);
+ } [Fact]
+ public void Test5()
+ {
+ Menu ferma = new Menu();
+ ferma.klet.Add("Boo");
+ Assert.Equal("Boo",ferma.klet[0]);
+ }
+ [Fact]
+ public void Test6()
+ {
+ Menu ferma = new Menu();
+ ferma.menu("Stl");
+ ferma.Name="Boo";
+ ferma.Pearent1="Buu";
+ ferma.Pearent2="Buuu";
+ Assert.Equal("Boo",ferma.klet[0]);
+ Assert.Equal("Buu",ferma.klet[0]);
+ Assert.Equal("Buuu",ferma.klet[0]);
+ }
+ [Fact]
+ public void Test7()
+ {
+ Menu ferma = new Menu();
+ var go="heip";
+ var osh="Такой команды не существует. help - узнать список команд.";
+ ferma.menu(go);
+ Assert.Equal(osh);
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/Cavy.cs b/CourseApp/Cavy.cs
new file mode 100644
index 0000000..9bc41de
--- /dev/null
+++ b/CourseApp/Cavy.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace CourseApp
+{
+ public class Cavy : Pet
+ {
+ public override void NewPet()
+ {
+ Console.Write("Введите имя новорожденной морской свинки: ");
+ Name = Console.ReadLine();
+ Console.WriteLine("Введите имена родителй морской свинки: ");
+ Pearent1 = Console.ReadLine();
+ Pearent2 = Console.ReadLine();
+ Spisok.Add(Name, new NewPet(Pearent1, Pearent2, "cavy"));
+ foreach(string i in Spisok.Keys)
+ {
+ if(Pearent1 == i )
+ {
+ Spisok.Add(Pearent1, new NewPet(Name, "cavy"));
+ }
+
+ if(Pearent2 == i)
+ {
+ Spisok.Add(Pearent2, new NewPet(Name, "cavy"));
+ }
+ }
+ }
+
+ public override string GetInfo()
+ {
+ return $"Морская свинка: {Name} ";
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj
index 23df604..cc0df39 100644
--- a/CourseApp/CourseApp.csproj
+++ b/CourseApp/CourseApp.csproj
@@ -3,6 +3,21 @@
Exe
netcoreapp2.1
+ True
+ 1573,1591,1701;1702;1705
+
+
+
+
+
+ ../stylecop/stylecop.ruleset
+ true
+
+
+
+
+
+
diff --git a/CourseApp/Date.cs b/CourseApp/Date.cs
new file mode 100644
index 0000000..c21aa68
--- /dev/null
+++ b/CourseApp/Date.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace CourseApp
+{
+ public class Date
+ {
+ public static string DateB(DateTime dr)
+ {
+ return DateTime.Today.AddYears(-dr.Year).AddMonths(-dr.Month).AddDays(-dr.Day).ToString("Год: yy Месяц: MM День: dd");
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/Krolik.cs b/CourseApp/Krolik.cs
new file mode 100644
index 0000000..b223085
--- /dev/null
+++ b/CourseApp/Krolik.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace CourseApp
+{
+ public class Krolik : Pet
+ {
+
+ public override void NewPet()
+ {
+ Console.Write("Введите имя новорожденного кролика: ");
+ Name = Console.ReadLine();
+ Console.WriteLine("Введите имена родителй кролика: ");
+ Pearent1 = Console.ReadLine();
+ Pearent2 = Console.ReadLine();
+ Spisok.Add(Name, new NewPet(Pearent1, Pearent2, "rabbit"));
+ foreach(string i in Spisok.Keys)
+ {
+ if(Pearent1 == i )
+ {
+ Spisok.Add(Pearent1, new NewPet(Name, "rabbit"));
+ }
+
+ if(Pearent2 == i)
+ {
+ Spisok.Add(Pearent2, new NewPet(Name, "rabbit"));
+ }
+ }
+ }
+
+ public override string GetInfo()
+ {
+ return $"Кролик: {Name} ";
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/Menu.cs b/CourseApp/Menu.cs
new file mode 100644
index 0000000..28601aa
--- /dev/null
+++ b/CourseApp/Menu.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace CourseApp
+{
+ public class Menu
+ {
+
+ PetStore petStore;
+ public Menu()
+ {
+ this.petStore = new PetStore();
+ }
+
+ public void MenuPets(string go)
+ {
+ switch (go)
+ {
+ case "Buy":
+ Console.WriteLine("Введите кого вы хоите купить: rabbit/cavy");
+ string type = Console.ReadLine();
+ this.petStore.CreatePet(type);
+ break;
+ case "Sel":
+ Console.WriteLine("Введите кого вы хоите разводить: rabbit/cavy");
+ string type = Console.ReadLine();
+ this.petStore.CreatePet(type);
+
+ break;
+ case "Art":
+ Art();
+ break;
+ case "Inf":
+ {
+ {
+ Console.Write("Введите имя животного о котором хотите унать: ");
+ Name = Console.ReadLine();
+ NewPet rrr = Spisok[Name];
+ PetInfo(rrr, Name);
+ }
+ }
+
+ break;
+ case "help":
+ Help();
+ break;
+ case "Info":
+ int kol = 1;
+ foreach (KeyValuePair i in Spisok)
+ {
+ Console.WriteLine(kol++ + ") " + i.Value.Vid + " " + i.Key);
+ }
+
+ break;
+ default:
+ if (go != "Stop")
+ {
+ Console.WriteLine("Такой команды не существует. help - узнать список команд.");
+ }
+
+ break;
+ }
+
+ Console.WriteLine("----------");
+ }
+
+ private static void Help()
+ {
+ Console.WriteLine(@"
+ Команды:
+ Stop - закончить программу;
+ Art - вывести рисунок кроликов;
+ Buy - купить нового кролика;
+ Sel - выростить нового кролика;
+ Info - узнать имена всех кроликов
+ Inf - узнать о конкретном кролике
+ ");
+ }
+
+ private static void Art()
+ {
+ Console.WriteLine(@"
+ ------/)/)------/),/)----(\__/)---(\.(\-----(\(\
+ -----(':'=)----(':'=)---(=';'=)---(=':')----(=':')
+ --(')('),,)-(')('),,)---(')_(')---(..(')(')-(..(')(') ");
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/Pet.cs b/CourseApp/Pet.cs
new file mode 100644
index 0000000..022f897
--- /dev/null
+++ b/CourseApp/Pet.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace CourseApp
+{
+ public abstract class Pet
+ {
+ public Pet() // Default constructor
+ :this("Noname")
+ {
+ }
+
+ public Pet(string name) // Default constructor
+ :this(name, null, null)
+ {
+ }
+
+ public Pet(string name, Pet parent1, Pet parent2) // Default constructor
+ {
+ this.Name = name;
+ this.Pearent1 = parent1;
+ this.Pearent2 = parent2;
+ }
+ public List Childs { get; set; }
+
+ public string Name {get; set; }
+
+ public Pet Pearent1 {get; set; }
+
+ public Pet Pearent2 {get; set; }
+
+ public override string ToString()
+ {
+ string tostr = $"{GetInfo()} \r\n";
+ if (Pearent1 != null || Pearent2 != null)
+ {
+ tostr += $", Родители: {Pearent1} и {Pearent2}";
+ }
+
+ if (Childs != null)
+ {
+ tostr += $", Дети: ";
+ foreach (var j in Childs)
+ {
+ tostr += $"{j} ";
+ }
+ }
+
+ return tostr;
+ }
+
+ public abstract string GetInfo();
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/PetStore.cs b/CourseApp/PetStore.cs
new file mode 100644
index 0000000..da36414
--- /dev/null
+++ b/CourseApp/PetStore.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace CourseApp
+{
+ public class PetStore
+ {
+ public Pet CreatePet(string type)
+ {
+ if (type == "Rabbit") //use switch case instead
+ {
+ return new Krolik();
+ }
+ else if (type == "Cavy")
+ {
+ return new Cavy();
+ }
+
+ }
+
+ // public Pet NewPet() // пока это не потребуется - и логика в buy Pet будет существовать
+ // {
+
+ // }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs
index c270f52..1274aea 100644
--- a/CourseApp/Program.cs
+++ b/CourseApp/Program.cs
@@ -2,11 +2,50 @@
namespace CourseApp
{
- class Program
+ public class Program
{
- static void Main(string[] args)
- {
- Console.WriteLine("Волошин Константин");
- }
- }
-}
+ public static void Main()
+ {
+ Console.WriteLine("Волошин Константин");
+ double a = 1.2;
+ double b = 0.48;
+ double xn = 0.7;
+ double xk = 2.2;
+ double dx = 0.3;
+ double[] xx = {0.25, 0.36, 0.56, 0.94, 1.28 };
+
+ Console.WriteLine("Задание А");
+ for(double x = xn; x < xk; x += dx)
+ {
+ Console.WriteLine(Fan(x, a, b));
+ }
+
+ Console.WriteLine("Задание B");
+ foreach(double x in xx)
+ {
+ Console.WriteLine(Fan(x, a, b));
+ }
+
+ Console.WriteLine("Задание на даты:");
+ DateTime dr = new DateTime(1999, 9, 17);
+ Console.WriteLine(Date.DateB(dr));
+
+ Console.WriteLine("Кроличья ферма!");
+
+ string go;
+ Menu start = new Menu();
+ do
+ {
+ go = Console.ReadLine();
+ start.MenuPets(go);
+ }
+ while(go != "Stop");
+ }
+
+ private static double Fan(double x, double a, double b)
+ {
+ double y = ((b * b * b) + (Math.Sin(a * x) * Math.Sin(a * x))) / (Math.Acos(x * b * x) + Math.Exp(-x / 2));
+ return y;
+ }
+ }
+}
\ No newline at end of file
diff --git a/stylecop/stylecop.json b/stylecop/stylecop.json
new file mode 100644
index 0000000..643b8c1
--- /dev/null
+++ b/stylecop/stylecop.json
@@ -0,0 +1,15 @@
+{
+ "$schema":
+ "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
+ "settings": {
+ "documentationRules": {
+ "documentExposedElements": false,
+ "documentInterfaces": false,
+ "companyName": "Test Company",
+ "copyrightText":
+ "This source code is Copyright © {companyName} and MAY NOT be copied, reproduced,\npublished, distributed or transmitted to or stored in any manner without prior\nwritten consent from {companyName} (www.yourcompany.com).",
+ "xmlHeader": false
+ }
+ },
+ "additionalArguments": ["./stylecop.ruleset", "./stylecop.json"]
+}
diff --git a/stylecop/stylecop.ruleset b/stylecop/stylecop.ruleset
new file mode 100644
index 0000000..3350d0e
--- /dev/null
+++ b/stylecop/stylecop.ruleset
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file