Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
Empty file added .vscode/launch.json
Empty file.
53 changes: 53 additions & 0 deletions CourseApp.Tests/DataTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;
using Xunit;

namespace CourseApp.Tests
{
public class DataTests
{
[Fact]
public void DataAfter()
{
DateTime a = new DateTime(2020, 12, 12);
DateTime b = new DateTime(2020, 12, 13);
var actualResult = Program.Date(a, b);
Assert.Equal("years = 0, months = 0, days = 1", actualResult);
}

[Fact]
public void Data1996()
{
DateTime a = new DateTime(1996, 12, 12);
DateTime b = new DateTime(2020, 12, 13);
var actualResult = Program.Date(a, b);
Assert.Equal("years = 24, months = 0, days = 1", actualResult);
}

[Fact]
public void Data2010()
{
DateTime a = new DateTime(2010, 12, 12);
DateTime b = new DateTime(2020, 12, 13);
var actualResult = Program.Date(a, b);
Assert.Equal("years = 10, months = 0, days = 1", actualResult);
}

[Fact]
public void DataQuals()
{
DateTime a = new DateTime(2020, 12, 12);
DateTime b = new DateTime(2020, 12, 12);
var actualResult = Program.Date(a, b);
Assert.Equal("years = 0, months = 0, days = 0", actualResult);
}

[Fact]
public void DataBefore()
{
DateTime a = new DateTime(2020, 12, 12);
DateTime b = new DateTime(2020, 12, 11);
var actualResult = Program.Date(a, b);
Assert.Equal("years = 0, months = 0, days = -1", actualResult);
}
}
}
2 changes: 1 addition & 1 deletion CourseApp/Country.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Country

public Country()
{
Console.WriteLine($"Население, площадь и плоность не заданы");
Console.WriteLine($"Население, площадь и плотность не заданы");
}

public Country(int population, int area, double density)
Expand Down
15 changes: 15 additions & 0 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ public static double Calc(double a, double b, double x)
return y;
}

public static string Date(DateTime olddate, DateTime zeroTime)
{
Console.WriteLine(olddate);
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Console.WriteLine(zeroTime);
int years = zeroTime.Year - olddate.Year;
int months = zeroTime.Month - olddate.Month;
int days = zeroTime.Day - olddate.Day;
return $"years = {years}, months = {months}, days = {days}";
Copy link
Contributor

Choose a reason for hiding this comment

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

не совсем правильно вычитать таким образом

}

public static (double x, double y)[] TaskA(double a, double b, double xn, double xk, double dx)
{
var res = new(double, double)[(int)Math.Ceiling((xk - xn) / dx) + 1];
Expand Down Expand Up @@ -75,6 +85,11 @@ public static void Main(string[] args)
country3.DensityInfo();
var union1 = new Union(5);
union1.UnionInfo();
Console.WriteLine();

DateTime zeroTime = DateTime.Today;
DateTime olddate = new DateTime(2020, 12, 9);
Console.WriteLine(Date(olddate, zeroTime));

Console.ReadKey();
}
Expand Down