Skip to content
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
30 changes: 30 additions & 0 deletions CourseApp.Tests/CourseApp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.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="..\CourseApp\CourseApp.csproj" />
</ItemGroup>

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

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

</Project>
14 changes: 14 additions & 0 deletions CourseApp.Tests/DemoTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using Xunit;

namespace CourseApp.Tests
{
public class DemoTest
{
[Fact]
public void Test1()
{
Assert.True(true);
}
}
}
59 changes: 59 additions & 0 deletions CourseApp.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using CourseApp;
using Xunit;

namespace Test
{
public class UnitTest1
{
[Fact]
public void Test1()
{
City ivanovo = new City();
var rescountry = ivanovo.Country;
var respopulation = ivanovo.Population;
var resname = ivanovo.Name;
Assert.Equal("Россия", rescountry);
Assert.Equal(316, respopulation);
Assert.Equal("Иваново", resname);
}

[Fact]
public void Test2()
{
City moscow = new City("Москва", "Россия");
var rescountry = moscow.Country;
var respopulation = moscow.Population;
var resname = moscow.Name;
Assert.Equal("Россия", rescountry);
Assert.Equal(11000, respopulation);
Assert.Equal("Москва", resname);
}

[Fact]
public void Test3()
{
City spb = new City("Питер", "Россия", 9000);
var rescountry = spb.Country;
var respopulation = spb.Population;
var resname = spb.Name;
Assert.Equal("Россия", rescountry);
Assert.Equal(9000, respopulation);
Assert.Equal("Питер", resname);
}

[Fact]
public void Test4()
{
var res = Program.Formula(0.1, 0.5, 0.15);
Copy link
Contributor

Choose a reason for hiding this comment

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

Эти тесты должны быть в отдельном файле

Copy link
Contributor

Choose a reason for hiding this comment

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

Это упорно игнорируете :(

Assert.Equal(0.001, res, 3);
}

[Fact]
public void Test5()
{
var res = Program.Formula(0.0, 0.0, 0.1);
Assert.Equal(0.0, res, 3);
}
}
}
17 changes: 16 additions & 1 deletion CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1573,1591,1701;1702;1705</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="all" />
</ItemGroup>

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

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

</Project>
31 changes: 31 additions & 0 deletions CourseApp/CourseApp.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2037
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp", "CourseApp.csproj", "{3F1471F2-2FB2-4B42-BC14-ECEA29012CB4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CourseApp.Tests", "..\CourseApp.Tests\CourseApp.Tests.csproj", "{5919BA31-3171-43C7-B452-E5EA9330F77A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3F1471F2-2FB2-4B42-BC14-ECEA29012CB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F1471F2-2FB2-4B42-BC14-ECEA29012CB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F1471F2-2FB2-4B42-BC14-ECEA29012CB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F1471F2-2FB2-4B42-BC14-ECEA29012CB4}.Release|Any CPU.Build.0 = Release|Any CPU
{5919BA31-3171-43C7-B452-E5EA9330F77A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5919BA31-3171-43C7-B452-E5EA9330F77A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5919BA31-3171-43C7-B452-E5EA9330F77A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5919BA31-3171-43C7-B452-E5EA9330F77A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0AB63177-0A3F-4523-9C64-57B9FF0F9AE0}
EndGlobalSection
EndGlobal
74 changes: 74 additions & 0 deletions CourseApp/Metropolis.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;

namespace CourseApp
{
public abstract class Metropolis
{
private int population;

public Metropolis()
{
Name = "Иваново";
population = 316;
}

public string Name { get; set; }
{
public class City
Copy link
Contributor

Choose a reason for hiding this comment

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

Воу воу - сразу нет - 1 файл 1 класс

{
private int population;

public City()
: this("Иваново", "Россия", 316)
{
} // 1 конструктор

public City(string name, string country)
: this(name, country, 11000)
{
} // 2 конструктор

public City(string name, string country, int population)
{
Name = name;
Country = country;
Population = population;
} // 3 конструктор

public string Country { get; set; }

public string Name { get; set; }

public int Population
{
get
{
return population;
}

set
{
if (value > 0)
{
this.population = value;
}
}
}

public void GetInfo()
{
Console.WriteLine($"Название: {Name} Страна: {Country} Популяция: {population}");
}

public void AddPopulation(int pop)
{
population += pop;
}

public string Dead()
{
return $"Всё население города {Name} вымерло из-за аварии на АЭС.";
}
}
}
}
52 changes: 49 additions & 3 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,58 @@
using System;
using static CourseApp.Metropolis;

namespace CourseApp
{
class Program
public class Program
{
static void Main(string[] args)
public static double Formula(double x, double a, double b) => (a + ((Math.Sin(b * x) * Math.Sin(b * x)) / (Math.Cos(b * x) * Math.Cos(b * x)))) / (b + (Math.Cos(a * x) * Math.Cos(a * x) / (Math.Sin(a * x) * Math.Sin(a * x))));

private static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.WriteLine("Анастасия Зайцева");
Console.WriteLine("вар 17");
Console.WriteLine();
Console.WriteLine("под А");
double a = 0.1;
double b = 0.5;
double xn = 0.15;
double xk = 1.37;
double dx = 0.25;
for (double x = xn; x <= xk; x = x + dx)
{
Console.WriteLine($" x={x} y={Math.Round(Formula(x, a, b), 3)}");
}

Console.WriteLine();
Console.WriteLine("под B");
double[] z = new double[] { 0.2, 0.3, 0.44, 0.6, 0.56 };
foreach (double element in z)
{
Console.WriteLine($" X={element} y={Math.Round(Formula(element, a, b), 3)} ");
}

City ivanovo = new City(); // вызов 1-ого
City moscow = new City("Москва", "Россия"); // вызов 2-ого
City peter = new City("Питер", "Россия", 9000); // вызов 3-ого
ivanovo.GetInfo();

ivanovo.Population = 5;
Console.WriteLine(ivanovo.Name);
ivanovo.GetInfo();
ivanovo.Population = -1;

ivanovo.GetInfo();

moscow.GetInfo();
peter.GetInfo();
ivanovo.AddPopulation(100);
ivanovo.GetInfo();

Console.WriteLine(ivanovo.Dead());
Console.WriteLine(moscow.Dead());
Console.WriteLine(peter.Dead());

Console.Read();
}
}
}
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# Course of c#

Please write your name and surname here
��������� �������
Copy link
Contributor

Choose a reason for hiding this comment

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

Можо каким-то другим редактором поддреживающим кодировку?

15 changes: 15 additions & 0 deletions stylecop/stylecop.json
Original file line number Diff line number Diff line change
@@ -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"]
}
22 changes: 22 additions & 0 deletions stylecop/stylecop.ruleset
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="StyleCopeRules" Description="StyleCopeRules custom ruleset" ToolsVersion="14.0">
<IncludeAll Action="None" />
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA1101" Action="None" />
<Rule Id="SA0001" Action="None" />
<Rule Id="SA1210" Action="None" />
<Rule Id="SA1633" Action="None" />
<Rule Id="SA1600" Action="None" />
<Rule Id="AD0001" Action="None" />
<Rule Id="CA2234" Action="None" />
<Rule Id="SA1200" Action="None" />
<Rule Id="SA1000" Action="None" />
<Rule Id="SA1012" Action="None" />
<Rule Id="SA1012" Action="None" />
<Rule Id="SA1009" Action="None" />
<Rule Id="SA1012" Action="None" />
<Rule Id="SA1652" Action="None" />
<Rule Id="CA1305" Action="None" />
<Rule Id="CA1056" Action="None" />
</Rules>
</RuleSet>