diff --git a/CourseApp.Tests/UnitTest5_DateTime.cs b/CourseApp.Tests/UnitTest5_DateTime.cs new file mode 100644 index 0000000..48ed3ca --- /dev/null +++ b/CourseApp.Tests/UnitTest5_DateTime.cs @@ -0,0 +1,33 @@ +using System; +using Xunit; + +using ConsoleApp1; + +namespace CourseApp.Tests +{ + public class UnitTest5_DateTime + { + private readonly Date td = new Date(); + + [Fact] + public void Test_data_2000_01_01() + { + DateTime bd = new DateTime(2000, 1, 1); + Assert.Equal(@"Year: 19 Month: 02 Day: 01 ", td.Vozrast(bd)); + } + + [Fact] + public void Test_data_1980_05_15() + { + DateTime bd = new DateTime(1980, 5, 15); + Assert.Equal(@"Year: 38 Month: 09 Day: 17 ", td.Vozrast(bd)); + } + + [Fact] + public void Test_data_1919_08_16() + { + DateTime bd = new DateTime(1919, 8, 16); + Assert.Equal(@"Year: 99 Month: 06 Day: 16 ", td.Vozrast(bd)); + } + } +} diff --git a/CourseApp/Date.cs b/CourseApp/Date.cs new file mode 100644 index 0000000..8113115 --- /dev/null +++ b/CourseApp/Date.cs @@ -0,0 +1,16 @@ +using System; + +namespace ConsoleApp1 +{ + public class Date + { + public string Vozrast(DateTime bd) + { + DateTime today = new DateTime(2019, 3, 2); + today = today.AddYears(-bd.Year); + today = today.AddMonths(-bd.Month); + today = today.AddDays(-bd.Day); + return today.ToString(@"\Year: yy \Mon\t\h: MM \Da\y: dd "); + } + } +} \ No newline at end of file diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs index 7bb62eb..92e1ff2 100644 --- a/CourseApp/Program.cs +++ b/CourseApp/Program.cs @@ -61,6 +61,9 @@ private static void Main() l.GetInfo(); } + Date td = new Date(); + DateTime bd = new DateTime(1999, 18, 8); + Console.WriteLine("vozrast = {bd.Vozrast(bd)}"); Console.Read(); } diff --git a/mihalks.github.io b/mihalks.github.io new file mode 160000 index 0000000..38f4ead --- /dev/null +++ b/mihalks.github.io @@ -0,0 +1 @@ +Subproject commit 38f4ead32cf6f003f8a9b4356c78c371901a45b6 diff --git a/sql/sql.txt b/sql/sql.txt new file mode 100644 index 0000000..e3975b1 --- /dev/null +++ b/sql/sql.txt @@ -0,0 +1,9 @@ +1)select title from Movie where director ="Steven Spielberg"; +2)select distinct year from Rating, Movie where stars >= 4 and Movie.mID=Rating.mID order by year; +3)select title from Movie where Movie.mID not in (select Rating.mID from Rating); +4)select name from Reviewer, Rating where Reviewer.rID=Rating.rID and Rating.ratingDate is null; +5)select distinct Reviewer.name, Movie.title, Rating.stars, Rating.ratingDate from (Movie join Rating) join Reviewer on Rating.mID=Movie.mID and Rating.rID=Reviewer.rID order by Reviewer.name, Movie.title, Rating.stars; +6)select distinct Reviewer.name, Movie.title from Movie, Reviewer, Rating R1,Rating R2 where R1.rID=Reviewer.rID and Movie.mID=R1.mID and R1.stars>R2.stars and R1.ratingDate > R2.ratingDate and (R1.rID=R2.rId and R1.ratingDate <> R2.ratingDate) and R1.ratingDate is not null and R2.ratingDate is not null and (R1.mID = R2.mId and R1.ratingDate <>R2.ratingDate); +7)select title, max(stars) from Rating, Movie where Rating.mID = Movie.mID group by Rating.mID; +8)select distinct title, avg(stars) from Movie, Rating where Movie.mID = Rating.mID group by title order by avg(stars) desc; +9)select distinct name from Rating, Reviewer where Rating.rID = Reviewer.rID and stars >= 3; \ No newline at end of file