diff --git a/CourseApp.Tests/CourseApp.Tests.sln b/CourseApp.Tests/CourseApp.Tests.sln index a80508b..334d2a8 100644 --- a/CourseApp.Tests/CourseApp.Tests.sln +++ b/CourseApp.Tests/CourseApp.Tests.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.27428.2002 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "CourseApp.Tests.csproj", "{F0AA3B44-F9EE-4875-88F6-26523A7914C9}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp", "..\CourseApp\CourseApp.csproj", "{A2F7EF9C-FCFB-496C-8974-05DA2E3DA7D5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {F0AA3B44-F9EE-4875-88F6-26523A7914C9}.Debug|Any CPU.Build.0 = Debug|Any CPU {F0AA3B44-F9EE-4875-88F6-26523A7914C9}.Release|Any CPU.ActiveCfg = Release|Any CPU {F0AA3B44-F9EE-4875-88F6-26523A7914C9}.Release|Any CPU.Build.0 = Release|Any CPU + {A2F7EF9C-FCFB-496C-8974-05DA2E3DA7D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A2F7EF9C-FCFB-496C-8974-05DA2E3DA7D5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A2F7EF9C-FCFB-496C-8974-05DA2E3DA7D5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A2F7EF9C-FCFB-496C-8974-05DA2E3DA7D5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CourseApp.Tests/UnitTest3.cs b/CourseApp.Tests/UnitTest3.cs index f22dbe3..07be501 100644 --- a/CourseApp.Tests/UnitTest3.cs +++ b/CourseApp.Tests/UnitTest3.cs @@ -1,6 +1,7 @@ using System; using Xunit; using ConsoleApp2; +using static ConsoleApp2.Furniture; namespace CourseApp.Tests { @@ -30,5 +31,73 @@ public void TestElementInMassive() Assert.Equal("Polsha", furniture[1].Produced); Assert.Equal("derevo", furniture[1].Material); } + + [Fact] + public void TestIComparable1() + { + Furniture[] furnitur = new Furniture[2]; + furnitur[0] = new Stol("B"); + furnitur[1] = new Shcaf("Aljir"); + Array.Sort(furnitur); + Assert.Equal("Aljir", furnitur[0].Name); + } + + [Fact] + public void TestIComparable2() + { + Furniture[] furnitur = new Furniture[4]; + furnitur[0] = new Stol("Ru"); + furnitur[1] = new Shcaf("Ge"); + furnitur[2] = new Shcaf("Al"); + furnitur[3] = new Stol("Be"); + Array.Sort(furnitur); + Assert.Equal("Al", furnitur[0].Name); + Assert.Equal("Be", furnitur[1].Name); + Assert.Equal("Ge", furnitur[2].Name); + Assert.Equal("Ru", furnitur[3].Name); + } + + [Fact] + public void TestIComparable3() + { + Furniture[] furnitur = new Furniture[4]; + furnitur[0] = new Stol("1"); + furnitur[1] = new Shcaf("A"); + furnitur[2] = new Shcaf("S"); + furnitur[3] = new Stol("2"); + Array.Sort(furnitur); + Assert.Equal("1", furnitur[0].Name); + Assert.Equal("2", furnitur[1].Name); + Assert.Equal("A", furnitur[2].Name); + Assert.Equal("S", furnitur[3].Name); + } + + [Fact] + public void TestIPrint1() + { + Stol stol2 = new Stol("Russia", 160, 200); + Assert.Equal("Stol", stol2.Mebel()); + } + + [Fact] + public void TestIPrint2() + { + Shcaf shcaf1 = new Shcaf("Russia", "Supastol", "береза"); + Assert.Equal("Schaf", shcaf1.Mebel()); + } + + [Fact] + public void TestIPrint3() + { + Stol stol3 = new Stol("Russia", 200, 200); + Assert.Equal(40000, stol3.Ploshad()); + } + + [Fact] + public void TestIPrint4() + { + Stol stol1 = new Stol("Rus", 160, 200); + Assert.Equal(32000, stol1.Ploshad()); + } } } \ No newline at end of file diff --git a/CourseApp/CourseApp.csproj b/CourseApp/CourseApp.csproj index b26cc56..1796139 100644 --- a/CourseApp/CourseApp.csproj +++ b/CourseApp/CourseApp.csproj @@ -7,6 +7,10 @@ 1573,1591,1701;1702;1705 + + + + diff --git a/CourseApp/Furniture.cs b/CourseApp/Furniture.cs index 4fe8867..16bb1b8 100644 --- a/CourseApp/Furniture.cs +++ b/CourseApp/Furniture.cs @@ -4,7 +4,7 @@ namespace ConsoleApp2 { using System; - public abstract class Furniture + public abstract partial class Furniture : IComparable, IPrint { private string produced; private string name; @@ -64,5 +64,20 @@ public override string ToString() } public abstract string GetInfo(); + + public int CompareTo(Furniture other) + { + return Name.CompareTo(other.Name); + } + + public virtual string Mebel() + { + return "Ya mebel'"; + } + + public int Ploshad() + { + return height * length; + } } } \ No newline at end of file diff --git a/CourseApp/IPrint.cs b/CourseApp/IPrint.cs new file mode 100644 index 0000000..2f8fdb9 --- /dev/null +++ b/CourseApp/IPrint.cs @@ -0,0 +1,9 @@ +namespace ConsoleApp2 +{ + public interface IPrint + { + string Mebel(); + + int Ploshad(); + } +} \ No newline at end of file diff --git a/CourseApp/Shcaf.cs b/CourseApp/Shcaf.cs index 1adf098..21e68d7 100644 --- a/CourseApp/Shcaf.cs +++ b/CourseApp/Shcaf.cs @@ -12,6 +12,11 @@ public Shcaf() Name = "chto-to"; } + public Shcaf(string name) + { + Name = name; + } + public Shcaf(string produced, string name, string material) : base(produced, name) { @@ -29,5 +34,10 @@ public override string GetInfo() { return $"Произведенно в:{Produced} Имя:{Name} Материал:{Material}"; } + + public override string Mebel() + { + return "Shcaf"; + } } } \ No newline at end of file diff --git a/CourseApp/Stol.cs b/CourseApp/Stol.cs index 95b6c0f..9bc4f6e 100644 --- a/CourseApp/Stol.cs +++ b/CourseApp/Stol.cs @@ -1,6 +1,4 @@ -using System; - -namespace ConsoleApp2 +namespace ConsoleApp2 { using System; @@ -12,6 +10,11 @@ public Stol() Produced = "Russia"; } + public Stol(string name) + { + Name = name; + } + public Stol(string produced, string name, int length, int height) : base(produced, name) { @@ -38,5 +41,10 @@ public override string GetInfo() { return $"Произведенно в : {Produced} Имя: {Name} Длина: {Lenght} Высота: {Height}"; } + + public override string Mebel() + { + return "Stol"; + } } } \ No newline at end of file diff --git a/Data program/.gitignore b/Data program/.gitignore new file mode 100644 index 0000000..33795ad --- /dev/null +++ b/Data program/.gitignore @@ -0,0 +1,316 @@ +# Download this file using PowerShell v3 under Windows with the following comand: +# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore +# or wget: +# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +**/[Bb]in/ +**/[Oo]bj/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# OS generated files # +.DS_Store* +Icon? + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +*.Cache +ClientBin/ +# [Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings +modulesbin/ +tempbin/ + +# EPiServer Site file (VPP) +AppData/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# vim +*.txt~ +*.swp +*.swo + +# svn +.svn + +# Remainings from resolvings conflicts in Source Control +*.orig + +# SQL Server files +**/App_Data/*.mdf +**/App_Data/*.ldf +**/App_Data/*.sdf + + +#LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +# SASS Compiler cache +.sass-cache + +# Visual Studio 2014 CTP +**/*.sln.ide + +# Visual Studio temp something +.vs/ + +# VS 2015+ +*.vc.vc.opendb +*.vc.db + +# Rider +.idea/ + +**/node_modules/* + +# Added by Jskonst +.vscode/ +# Migrations/ +Properties/ + +##### +# End of core ignore list, below put you custom 'per project' settings (patterns or path) +##### +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# Executable programs +*.exe \ No newline at end of file diff --git a/Data program/CourseApp.Tests/CourseApp.Tests.csproj b/Data program/CourseApp.Tests/CourseApp.Tests.csproj new file mode 100644 index 0000000..9534826 --- /dev/null +++ b/Data program/CourseApp.Tests/CourseApp.Tests.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp2.1 + + false + + + + + + + + + + + + + + diff --git a/Data program/CourseApp.Tests/CourseApp.Tests.sln b/Data program/CourseApp.Tests/CourseApp.Tests.sln new file mode 100644 index 0000000..1dcaa5f --- /dev/null +++ b/Data program/CourseApp.Tests/CourseApp.Tests.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.489 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "CourseApp.Tests.csproj", "{992B27CD-2FF3-4CEE-BB36-D17E06954889}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp", "..\CourseApp\CourseApp.csproj", "{E28EC136-CA74-4BBA-A72E-5796294626D9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {992B27CD-2FF3-4CEE-BB36-D17E06954889}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {992B27CD-2FF3-4CEE-BB36-D17E06954889}.Debug|Any CPU.Build.0 = Debug|Any CPU + {992B27CD-2FF3-4CEE-BB36-D17E06954889}.Release|Any CPU.ActiveCfg = Release|Any CPU + {992B27CD-2FF3-4CEE-BB36-D17E06954889}.Release|Any CPU.Build.0 = Release|Any CPU + {E28EC136-CA74-4BBA-A72E-5796294626D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E28EC136-CA74-4BBA-A72E-5796294626D9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E28EC136-CA74-4BBA-A72E-5796294626D9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E28EC136-CA74-4BBA-A72E-5796294626D9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {739635E1-026E-4192-9A88-7CDB8BBB04A9} + EndGlobalSection +EndGlobal diff --git a/Data program/CourseApp.Tests/ProgramTests.cs b/Data program/CourseApp.Tests/ProgramTests.cs new file mode 100644 index 0000000..ea63042 --- /dev/null +++ b/Data program/CourseApp.Tests/ProgramTests.cs @@ -0,0 +1,18 @@ +using System; +using Xunit; +using CourseApp; + +namespace CourseApp.Tests +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + DateTime res = new DateTime(2019, 04, 07); + DateTime bd = new DateTime(1999, 11, 23); + string d = "19 4 15"; + Assert.Equal(d, Data(res, bd)); + } + } +} diff --git a/Data program/CourseApp/CourseApp.csproj b/Data program/CourseApp/CourseApp.csproj new file mode 100644 index 0000000..26ccfdb --- /dev/null +++ b/Data program/CourseApp/CourseApp.csproj @@ -0,0 +1,24 @@ + + + + Exe + netcoreapp2.0 + True + 1573,1591,1701;1702;1705 + + + + + + + + + ../stylecop/stylecop.ruleset + true + + + + + + + diff --git a/Data program/CourseApp/Program.cs b/Data program/CourseApp/Program.cs new file mode 100644 index 0000000..3dba072 --- /dev/null +++ b/Data program/CourseApp/Program.cs @@ -0,0 +1,33 @@ +using System; + +namespace CourseApp +{ + public class Program + { + public static void Main() + { + string input = string.Empty; + DateTime birthday = default(DateTime); + DateTime today = DateTime.Now; + do + { + input = Console.ReadLine(); + } + while (!DateTime.TryParseExact(input, "dd.MM.yyyy", null, System.Globalization.DateTimeStyles.None, out birthday)); + string data = Data(today, birthday); + Console.WriteLine(data); + } + + public static string Data(DateTime today, DateTime birthday) + { + string data = string.Empty; + long dataChela = today.Ticks - birthday.Ticks; + DateTime pDate = new DateTime(dataChela); + int year = pDate.Year - 1; + int month = pDate.Month - 1; + int day = pDate.Day - 1; + data = year + " " + month + " " + day; + return data; + } + } +} \ No newline at end of file diff --git a/Data program/README.md b/Data program/README.md new file mode 100644 index 0000000..d797201 --- /dev/null +++ b/Data program/README.md @@ -0,0 +1,3 @@ +# Course of c# + +Murashov Viktor diff --git a/Data program/stylecop/stylecop.json b/Data program/stylecop/stylecop.json new file mode 100644 index 0000000..643b8c1 --- /dev/null +++ b/Data program/stylecop/stylecop.json @@ -0,0 +1,15 @@ +{ + "$schema": + "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", + "settings": { + "documentationRules": { + "documentExposedElements": false, + "documentInterfaces": false, + "companyName": "Test Company", + "copyrightText": + "This source code is Copyright © {companyName} and MAY NOT be copied, reproduced,\npublished, distributed or transmitted to or stored in any manner without prior\nwritten consent from {companyName} (www.yourcompany.com).", + "xmlHeader": false + } + }, + "additionalArguments": ["./stylecop.ruleset", "./stylecop.json"] +} diff --git a/Data program/stylecop/stylecop.ruleset b/Data program/stylecop/stylecop.ruleset new file mode 100644 index 0000000..3350d0e --- /dev/null +++ b/Data program/stylecop/stylecop.ruleset @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SQL LAB/rating.sql b/SQL LAB/rating.sql new file mode 100644 index 0000000..e86f63c --- /dev/null +++ b/SQL LAB/rating.sql @@ -0,0 +1,44 @@ +/* Delete the tables if they already exist */ +drop table if exists Movie; +drop table if exists Reviewer; +drop table if exists Rating; + +/* Create the schema for our tables */ +create table Movie(mID int, title text, year int, director text); +create table Reviewer(rID int, name text); +create table Rating(rID int, mID int, stars int, ratingDate date); + +/* Populate the tables with our data */ +insert into Movie values(101, 'Gone with the Wind', 1939, 'Victor Fleming'); +insert into Movie values(102, 'Star Wars', 1977, 'George Lucas'); +insert into Movie values(103, 'The Sound of Music', 1965, 'Robert Wise'); +insert into Movie values(104, 'E.T.', 1982, 'Steven Spielberg'); +insert into Movie values(105, 'Titanic', 1997, 'James Cameron'); +insert into Movie values(106, 'Snow White', 1937, null); +insert into Movie values(107, 'Avatar', 2009, 'James Cameron'); +insert into Movie values(108, 'Raiders of the Lost Ark', 1981, 'Steven Spielberg'); + +insert into Reviewer values(201, 'Sarah Martinez'); +insert into Reviewer values(202, 'Daniel Lewis'); +insert into Reviewer values(203, 'Brittany Harris'); +insert into Reviewer values(204, 'Mike Anderson'); +insert into Reviewer values(205, 'Chris Jackson'); +insert into Reviewer values(206, 'Elizabeth Thomas'); +insert into Reviewer values(207, 'James Cameron'); +insert into Reviewer values(208, 'Ashley White'); + +insert into Rating values(201, 101, 2, '2011-01-22'); +insert into Rating values(201, 101, 4, '2011-01-27'); +insert into Rating values(202, 106, 4, null); +insert into Rating values(203, 103, 2, '2011-01-20'); +insert into Rating values(203, 108, 4, '2011-01-12'); +insert into Rating values(203, 108, 2, '2011-01-30'); +insert into Rating values(204, 101, 3, '2011-01-09'); +insert into Rating values(205, 103, 3, '2011-01-27'); +insert into Rating values(205, 104, 2, '2011-01-22'); +insert into Rating values(205, 108, 4, null); +insert into Rating values(206, 107, 3, '2011-01-15'); +insert into Rating values(206, 106, 5, '2011-01-19'); +insert into Rating values(207, 107, 5, '2011-01-20'); +insert into Rating values(208, 104, 3, '2011-01-02'); + diff --git a/SQL LAB/sql.txt b/SQL LAB/sql.txt new file mode 100644 index 0000000..75c9b9b --- /dev/null +++ b/SQL LAB/sql.txt @@ -0,0 +1,9 @@ +1)select Title FROM movie WHERE director = 'Steven Spielberg'; +2)select year from movie where mID IN (select mID from rating where stars>3) ORDER BY year; +3)select title from movie where mid in (select Movie.mID from Movie Left Join Rating on Rating.mID = Movie.mID where Rating.mID is null); +4)select name from Reviewer where rID IN (select rID from rating where ratingDate IS NULL); +5)select name,title,stars,ratingdate from movie,reviewer left join rating on reviewer.rid=rating.rid where movie.mid=rating.mid order by 1,2,3; +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 name from reviewer where rid IN (select rid from (select rid,count(rid) from rating group by rid having count(rid)>2)); \ No newline at end of file diff --git a/SQL LAB/sqlite-start.sql b/SQL LAB/sqlite-start.sql new file mode 100644 index 0000000..8b51223 Binary files /dev/null and b/SQL LAB/sqlite-start.sql differ