Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rpg #78

Open
wants to merge 11 commits into
base: Viktor_Morohovtsev
Choose a base branch
from
Open

Rpg #78

Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ $RECYCLE.BIN/
**/node_modules/*

# Added by Jskonst
.vscode/
Properties/

#####
Expand Down
41 changes: 0 additions & 41 deletions CourseApp.Tests/DemoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,5 @@ public void Test1()
{
Assert.True(true);
}

[Fact]
public void TestMyFunctionZeros()
{
var res = Program.Formula(0.0, 0.0);
Assert.Equal(double.NaN, res);
}

[Fact]
public void TestTaskB()
{
List<double> x = new List<double> { 1.84, 4.05, 3.67, 2.18, 1.17 };
List<double> res = Program.TaskB(1.6, x);
List<double> expy = new List<double> { 3.691061372588238, 1392.8345934281351, 350.7785466064311, 6.25933353327923, 2.622414465082322 };
for (int i = 0; i < 5; i++)
{
Assert.Equal(expy[i], res[i], 3);
}
}

[Fact]
public void TestTaskA()
{
double a = 1.6;
double xn = 1.2;
double xk = 3.7;
double dx = 0.5;
List<double> res = Program.TaskA(a, xn, xk, dx);
List<double> expy = new List<double> { 2.58628588710697, 3.15454831838707, 6.49450906742811, 19.428489457705, 76.9595290357977 };
for (int i = 0; i < 5; i++)
{
Assert.Equal(expy[i], res[i], 3);
}
}

[Fact]
public void XnMoreThanXkAndUncorrectDx()
{
List<double> res = Program.TaskA(1.6, 3.7, 1.2, 0.7);
Assert.Equal(res, new List<double>());
}
}
}
78 changes: 0 additions & 78 deletions CourseApp.Tests/PersonTest.cs

This file was deleted.

61 changes: 0 additions & 61 deletions CourseApp/Person.cs

This file was deleted.

61 changes: 0 additions & 61 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,8 @@ namespace CourseApp
{
public class Program
{
public static double Formula(double a, double x)
{
var y = Math.Pow(a, Math.Pow(x, 2) - 1) - Math.Log10(Math.Pow(x, 2) - 1) + Math.Pow(Math.Sqrt(Math.Pow(x, 2) - 1), 1 / 3);
return y;
}

public static List<double> TaskA(double a, double xn, double xk, double dx)
{
if (xk < xn)
{
return new List<double>();
}
else
{
List<double> y = new List<double>((int)((xk - xn) / dx));
for (double x = xn; x < xk; x += dx)
{
y.Add(Formula(a, x));
}

return y;
}
}

public static List<double> TaskB(double a, List<double> x)
{
List<double> y = new List<double>();
for (var i = 0; i < x.Count; i++)
{
y.Add(Formula(a, x[i]));
}

return y;
}

public static void Main(string[] args)
{
const double a = 1.6;
const double xn = 1.2;
const double xk = 3.7;
const double dx = 0.5;
Console.WriteLine("Task А:");
foreach (var item in TaskA(a, xn, xk, dx))
{
Console.WriteLine($"y = {item}");
}

Console.WriteLine("Task B:");
List<double> x = new List<double> { 1.28, 1.36, 2.47, 3.68, 4.56 };
foreach (var item in TaskB(a, x))
{
Console.WriteLine($"y = {item}");
}

Person[] people = new Person[2];
people[0] = new Person("Sasha", "Smirnov", 25);
people[1] = new Person("Polina", "Suvorova", 22);
foreach (var item in people)
{
Console.WriteLine(item);
}

Console.ReadLine();
}
}
}
30 changes: 30 additions & 0 deletions RPG.Tests/RPG.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1573,1591,1701;1702;1705</NoWarn>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="all" />
</ItemGroup>

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

<PropertyGroup>
<CodeAnalysisRuleSet>../_stylecop/stylecop.ruleset</CodeAnalysisRuleSet>
<GenerateFullPaths>true</GenerateFullPaths>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="../_stylecop/stylecop.json" />
</ItemGroup>

</Project>
Loading