Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CourseApp.Tests/CourseApp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CourseApp\CourseApp.csproj" />
</ItemGroup>

</Project>
58 changes: 58 additions & 0 deletions CourseApp.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
72 changes: 72 additions & 0 deletions CourseApp.Tests/UnitTest2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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 Rabbit();
var N ="momo";
krosh.RabbitInfo(N);
Assert.Equal("momo",N);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

этот тест не проверяет ващ класс - он только проверяет что переменная N, объявленная в тесте = "momo"

}
[Fact]
public void Test2()
{
var krosh = new Rabbit();
var N ="momo";
var P1 = "mu";
var P2 = "nu";
krosh.RabbitInfo(N);
Assert.Equal("momo",N);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Та же беда - вы проверяете не свойство класса, а проверяете значение переменных, которые объявлены в тесте

Assert.Equal("mu",P1);
Assert.Equal("nu",P2);
}
[Fact]
public void Test3()
{
var krosh = new Rabbit();
var N ="momo";
var P1 = "mu";
var P2 = "nu";
List<string> ch=new List<string> {"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]);
}
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]);
}
}
}
17 changes: 17 additions & 0 deletions CourseApp/Farm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;

namespace CourseApp
{
public class Farm
{
public List<string> Child=new List<string>();
public string Name{get;set;}
public string Pearent1 {get;set;}
public string Pearent2 {get;set;}

public Farm() {}
public Farm(string n) {this.Name=n;}
public Farm(string n, string p1,string p2) {this.Name=n;this.Pearent1=p1;this.Pearent2=p2;}
}
}
90 changes: 90 additions & 0 deletions CourseApp/Menu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System;
using System.Collections;
using System.Collections.Generic;

namespace CourseApp
{
public class Menu:Farm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут наследование не совсем верно применено - ну или как минимум именование - мен. не является фермой

{
public Rabbit info = new Rabbit();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

имя переменной не информативно - info? но при этом класс кролика

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если это меню, то это толкьо меню!

public ArrayList klet= new ArrayList();
public void menu(string go)
{
switch (go)
{
case "help":
help();
break;
case "Buy":
Console.Write("Введите имя купленного кролика: ");
Name = Console.ReadLine();
klet.Add(new Farm(Name));
break;
case "Sel":
Console.Write ("Введите имя новорожденного кролика: ");
Name = Console.ReadLine();
Console.WriteLine("Введите имена родителй кролика: ");
Pearent1=Console.ReadLine();
Pearent2=Console.ReadLine();
klet.Add(new Farm(Name,Pearent1,Pearent2));
foreach(Farm i in klet)
{
if(Pearent1==i.Name||Pearent2==i.Name){i.Child.Add(Name);};
}
break;
case "Art":
art();
break;
case "Info": int num=1;
foreach(Farm i in klet)
{
Console.WriteLine($"{num++}) {i.Name}");
}
break;
case "Inf":
{
Console.Write("Введите имя кролика о котором хотите унать: ");
Name = Console.ReadLine();
foreach(Farm i in klet)
{
if(i.Name==Name)
{
if (i.Pearent1 == null && i.Child.Count == 0)
{info.RabbitInfo(i.Name);}
else if(i.Pearent1 != null && i.Child.Count == 0)
{info.RabbitInfo(i.Name,i.Pearent1,i.Pearent2);}
else if(i.Pearent1 == null && i.Child.Count != 0)
{info.RabbitInfo(i.Name,i.Child);}
else if(i.Pearent1 != null && i.Child.Count != 0)
{info.RabbitInfo(i.Name,i.Pearent1,i.Pearent2,i.Child);}
}
}
}
break;
default: if(go != "Stop") {
Console.WriteLine("Такой команды не существует. help - узнать список команд.");}
break;
}
Console.WriteLine("----------");
}
static void help()
{
Console.WriteLine(@"
Команды:
Stop - закончить программу;
Art - вывести рисунок кроликов;
Buy - купить нового кролика;
Sel - выростить нового кролика;
Info - узнать имена всех кроликов
Inf - узнать о конкретном кролике
");
}
static void art()
{
Console.WriteLine(@"
------/)/)------/),/)----(\__/)---(\.(\-----(\(\
-----(':'=)----(':'=)---(=';'=)---(=':')----(=':')
--(')('),,)-(')('),,)---(')_(')---(..(')(')-(..(')(') ");
}
}
}
46 changes: 39 additions & 7 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,43 @@

namespace CourseApp
{
class Program
public class Program
{
static void Main(string[] args)
{
Console.WriteLine("Волошин Константин");
}
}
}

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 ("Кроличья ферма!");

string go;
Menu start = new Menu();
do
{
go=Console.ReadLine();
start.menu(go);
}
while(go!="Stop");
}
public 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;
}
}
}
15 changes: 15 additions & 0 deletions CourseApp/RabbitInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;

namespace CourseApp
{
public class Rabbit
{
public void RabbitInfo(string Name, string Pearent1,string Pearent2, List<string> Child)
{Console.Write($"Кролик {Name}, Родители: {Pearent1} и {Pearent2}, Дети: ");foreach(var i in Child){Console.WriteLine($"{i} ");}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Разбейте на несколько строк, читать очень сложно

public void RabbitInfo(string Name, string Pearent1,string Pearent2) {Console.WriteLine($"Кролик {Name}, Родители: {Pearent1} и {Pearent2}, Детей нет");}
public void RabbitInfo(string Name) {Console.WriteLine($"Кролик {Name}, Родители: ??? и ???, Дети нет");}
public void RabbitInfo(string Name, List<string> Child)
{Console.Write($"Кролик {Name}, Родители: ??? и ???, Дети: ");foreach(var i in Child){Console.WriteLine($"{i} ");} }
}
}