Skip to content
46 changes: 46 additions & 0 deletions CourseApp/City.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;

namespace CourseApp
{
public class City
{
public string Country { get; set; }
private int population;
public string Name { get; set; }

public int Population
{
get
{
return population;
}
set
{
if (value > 0)
{
this.population = value;
}

}
}

public City() { Name = "Иваново"; Country = "Россия"; population = 316; } // 1 конструктор
Copy link
Contributor

Choose a reason for hiding this comment

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

Переиспользуйте конструктор - данный донструктор без параметров должен вызвать основной констурктор, передав ему все параметры


public City(string n, string m) { Name = n; Country = m; population = 11000; } // 2 конструктор

public City(string n, string m, int a) { Name = n; Country = m; population = a; } // 3 конструктор
public void GetInfo()
{
Console.WriteLine($"Название: {Name} Страна: {Country} Популяция: {population}");
}
public void s(int pop)
{
population += pop;
}
public void Ueh()
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($"Из-за ужасной ядерной катастрофы всё население Иванова вымерло");
}

}
}
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>
</PropertyGroup>

</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}") = "test", "..\test\test.csproj", "{F41FC357-FFB9-4654-9C10-87F548367AD4}"
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
{F41FC357-FFB9-4654-9C10-87F548367AD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F41FC357-FFB9-4654-9C10-87F548367AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F41FC357-FFB9-4654-9C10-87F548367AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F41FC357-FFB9-4654-9C10-87F548367AD4}.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
53 changes: 51 additions & 2 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,60 @@

namespace CourseApp
{
class Program
public class Program
{
public static double formula(double x, double a, double b)
{
return (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))))));

}
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.s(100);
ivanovo.GetInfo();

ivanovo.Ueh();

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.

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

38 changes: 38 additions & 0 deletions laba2/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;

namespace CourseApp3
{
class Program4
{

static void Main(string[] args)
{
double xn = 0.15;
double xk = 1.37;
double dx = 0.25;
double[] xx = { 0.2, 0.3, 0.44, 0.6, 0.56 };

Console.WriteLine("под А");

for (double x = xn; x < xk; x += dx)
{
Console.WriteLine(Fan(x));

}
Console.WriteLine("под B");
foreach (double x in xx)
{
Console.WriteLine(Fan(x));
}
}
static double Fan(double x)
{
double a = 0.1;
Copy link
Contributor

Choose a reason for hiding this comment

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

a и b следует также вынести в параметры функции

Copy link
Contributor

Choose a reason for hiding this comment

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

Так и не изменено :(

double b = 0.5;
double y;
y = ((a + (Math.Tan(b * x)) * (Math.Tan(b * x))) / (b + (1 / (Math.Tan(a * x))) * (1 / (Math.Tan(a * x)))));
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.

Объедините объявление и присвоение

return y;
}

}
}
55 changes: 55 additions & 0 deletions test/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using Xunit;
using CourseApp;

namespace test
{
public class UnitTest1
{
[Fact]
public void Test1()
{
City ivanovo = new City();
var res_country = ivanovo.Country;
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.

А вот стиль названия с _ в имени - не принят - поправьте

var res_population = ivanovo.Population ;
var res_name = ivanovo.Name;
Assert.Equal("������", res_country);
Assert.Equal(316, res_population);
Assert.Equal("�������", res_name);
}
[Fact]
public void Test2()
{
City moscow = new City("������","������");
var res_country = moscow.Country;
var res_population = moscow.Population;
var res_name = moscow.Name;
Assert.Equal("������", res_country);
Assert.Equal(11000, res_population);
Assert.Equal("������", res_name);
}
[Fact]
public void Test3()
{
City spb = new City("�����", "������", 9000);
var res_country = spb.Country;
var res_population = spb.Population;
var res_name = spb.Name;
Assert.Equal("������", res_country);
Assert.Equal(9000, res_population);
Assert.Equal("�����", res_name);
}
[Fact]
Copy link
Contributor

Choose a reason for hiding this comment

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

Это почему тут осталось?

public void Test4()
{
var res = Program.formula(0.1, 0.5, 0.15);
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);
}
}
}
20 changes: 20 additions & 0 deletions test/test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CourseApp\CourseApp.csproj" />
</ItemGroup>

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

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}") = "test", "test.csproj", "{54005DE3-DDA5-4054-B1E5-C615C6978944}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{54005DE3-DDA5-4054-B1E5-C615C6978944}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{54005DE3-DDA5-4054-B1E5-C615C6978944}.Debug|Any CPU.Build.0 = Debug|Any CPU
{54005DE3-DDA5-4054-B1E5-C615C6978944}.Release|Any CPU.ActiveCfg = Release|Any CPU
{54005DE3-DDA5-4054-B1E5-C615C6978944}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4F11FC6D-B967-4BB4-B687-47D6434B6F5D}
EndGlobalSection
EndGlobal
25 changes: 25 additions & 0 deletions олцурашдуцрацдшра/ConsoleApp6/ConsoleApp6.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2037
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp6", "ConsoleApp6\ConsoleApp6.csproj", "{8DB91C96-3426-4D10-8352-4A179858C483}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8DB91C96-3426-4D10-8352-4A179858C483}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DB91C96-3426-4D10-8352-4A179858C483}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DB91C96-3426-4D10-8352-4A179858C483}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DB91C96-3426-4D10-8352-4A179858C483}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CA85E5A4-6EF8-429A-9DCE-3C7AD673C43E}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;

namespace CourseApp
{
class City
{
public string country;
public int population;
public string name;

public City() { name = "Иваново"; country = "Россия"; population = 316 ; } // 1 конструктор
Copy link
Contributor

Choose a reason for hiding this comment

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

Уберите все ненужные файлы


public City(string n, string m) { name = n; country = m; population = 11000; } // 2 конструктор

public City(string n, string m, int a) { name = n; country = m; population = a; }
public void GetInfo()
{
Console.WriteLine($"Название: {name} Страна: {country} Популяция: {population}");
}
public void s(int pop)
{
population += pop;
}
public void Ueh()
{
Console.WriteLine($"Из-за ужасной ядерной катастрофы всё население Иванова вымерло");
}

}
class Program
{
static void Main(string[] args)
{
City ivanovo = new City(); // вызов 1-ого конструктора без параметров
City moscow = new City("Москва", "Россия"); //вызов 2-ого конструктора с одним параметром
City peter = new City("Питер", "Россия", 9000);


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


ivanovo.s(100);
ivanovo.GetInfo();

ivanovo.Ueh();

Console.Read();
}
}
}