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

Added initial lab #59

Open
wants to merge 3 commits into
base: Nikita_Bogomazov
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// Используйте IntelliSense, чтобы узнать о возможных атрибутах.
// Наведите указатель мыши, чтобы просмотреть описания существующих атрибутов.
// Для получения дополнительной информации посетите: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
}
2 changes: 1 addition & 1 deletion CourseApp.Tests/CourseApp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1573,1591,1701;1702;1705</NoWarn>
<IsPackable>false</IsPackable>
Expand Down
45 changes: 37 additions & 8 deletions CourseApp.Tests/DemoTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Xunit;

namespace CourseApp.Tests
Expand All @@ -8,17 +10,44 @@ public class DemoTest
[Fact]
public void Test1()
{
Assert.True(true);
Xunit.Assert.True(true);
}

[Fact]
public void TestMyFunctionZeros()
{
var res = Program.MyFunction(1.0, 0.0, 0.0);
Xunit.Assert.Equal(0, res);
}

[Theory]
[InlineData(0, 0, 0, 0)]
[InlineData(0, 2, 1, 2)]
[InlineData(1, 2, 1, 3)]
public void TestFunctionCalculationVal(double a, double b, double x, double exp)
[InlineData(2.0, 3.0, 0.11, 0.36, 0.05)]
public void TestElementsA(double a, double b, double xn, double xk, double dx)
{
var res = Program.TaskA(a, b, xn, xk, dx);
ArrayList list = new ArrayList() { a, b, xn, xk, dx };
double massElemExpected = (xk - xn) / dx;
Xunit.Assert.Equal(massElemExpected, list.Count);
}

[Fact]
public void TestTaskBNullMass()
{
List<double> mass = new List<double>();
var res = Program.TaskB(1, 2, mass);
Xunit.Assert.Equal(mass, res);
}

[Fact]
public void TestTaskB()
{
var res = Program.MyFunction(a, b, x);
Assert.Equal(exp, res, 3);
List<double> x = new List<double> { 0.08, 0.26, 0.35, 0.41, 0.53 };
var res = Program.TaskB(2.0, 3.0, x);
var expy = new double[] { 1.576684370464, 1.62087101387868, 1.65071664516254, 1.67072256986309, 1.70609554498699 };
for (int i = 0; i < 5; i++)
{
Xunit.Assert.Equal(expy[i], res[i], 3);
}
}
}
}
}
1 change: 1 addition & 0 deletions CourseApp/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": ".NET Core Launch (console)",
"type": "coreclr",
Expand Down
2 changes: 1 addition & 1 deletion CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1573,1591,1701;1702;1705;</NoWarn>
</PropertyGroup>
Expand Down
55 changes: 36 additions & 19 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,46 +1,63 @@
using System;
using System.Collections.Generic;
using System.Collections;

namespace CourseApp
{
public class Program
{
public static double MyFunction(double a, double b, double x)
public static double MyFunction(double a, double b, double x)
{
var y = (a * Math.Pow(x, 2)) + (b * x);
var y = Math.Asin(Math.Pow(x, a)) + Math.Acos(Math.Pow(x, b));
return y;
}

public static double[] TaskA(double a, double b, double xn, double xk, double dx)
public static List<double> TaskA(double a, double b, double xn, double xk, double dx)
{
return new double[0];
List<double> y = new List<double>();
for (double x = xn; x < xk; x += dx)
{
y.Add(MyFunction(a, b, x));
}

return y;
}

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

return y;
}

public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
const double a = 2.2;
const double b = 3.8;
var resSingle = MyFunction(a, b, 4);
Console.WriteLine(resSingle);
var x = new double[] { 1, 2, 3, 4, 5 };
var taskBRes = TaskB(a, b, x);
foreach (var item in taskBRes)
const double a = 2.0;
const double b = 3.0;
const double xn = 0.11;
const double xk = 0.36;
const double dx = 0.05;
double count = xn;
Console.WriteLine("Task A:");
foreach (var i in TaskA(a, b, xn, xk, dx))
{
Console.WriteLine($"x = {count += dx}, y = {i}");
}

Console.WriteLine();
List<double> x = new List<double> { 0.08, 0.26, 0.35, 0.41, 0.53 };
count = 0;
Console.WriteLine("Task B:");
foreach (var i in TaskB(a, b, x))
{
Console.WriteLine($"y = {item}");
Console.WriteLine($"x = {x[(int)count++]}, y = {i}");
}

Console.ReadLine();
Console.ReadKey();
}
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Tprogramming_42_2019
# Nikita Bogomazov