Browse Source

complete, but not fulld

ЗименковНИ 2 years ago
parent
commit
996a564b10
7 changed files with 235 additions and 1 deletions
  1. 6 0
      PM02.sln
  2. 33 0
      PM02/Output.txt
  3. 71 1
      PM02/Program.cs
  4. 20 0
      UnitTest/Properties/AssemblyInfo.cs
  5. 74 0
      UnitTest/UnitTest.csproj
  6. 26 0
      UnitTest/UnitTest1.cs
  7. 5 0
      UnitTest/packages.config

+ 6 - 0
PM02.sln

@@ -5,6 +5,8 @@ VisualStudioVersion = 17.2.32526.322
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PM02", "PM02\PM02.csproj", "{517871A9-AAAC-4081-A925-C87D8C720EF4}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "UnitTest\UnitTest.csproj", "{058A4617-618C-47A0-B030-5529B486B119}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
 		{517871A9-AAAC-4081-A925-C87D8C720EF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{517871A9-AAAC-4081-A925-C87D8C720EF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{517871A9-AAAC-4081-A925-C87D8C720EF4}.Release|Any CPU.Build.0 = Release|Any CPU
+		{058A4617-618C-47A0-B030-5529B486B119}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{058A4617-618C-47A0-B030-5529B486B119}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{058A4617-618C-47A0-B030-5529B486B119}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{058A4617-618C-47A0-B030-5529B486B119}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 33 - 0
PM02/Output.txt

@@ -0,0 +1,33 @@
+Баланс: 0. За год 0 / 1%
+Баланс: 11557.9. За год 1557.9 / 1%
+Баланс: 23722.96. За год 3722.96 / 1%
+Баланс: 36539.9. За год 6539.9 / 2%
+Баланс: 50057.7. За год 10057.7 / 2%
+Баланс: 64330.19. За год 14330.19 / 2%
+Баланс: 79416.35. За год 19416.35 / 3%
+Баланс: 95381.37. За год 25381.37 / 3%
+Баланс: 112297.09. За год 32297.09 / 3%
+Баланс: 130242.92. За год 40242.92 / 4%
+Баланс: 149306.9. За год 49306.9 / 4%
+Баланс: 169586.89. За год 59586.89 / 4%
+Баланс: 191191.43. За год 71191.43 / 5%
+Баланс: 214242.41. За год 84242.41 / 5%
+Баланс: 238875.25. За год 98875.25 / 6%
+Баланс: 265242.43. За год 115242.43 / 6%
+Баланс: 293515.05. За год 133515.05 / 7%
+Баланс: 323886.32. За год 153886.32 / 7%
+Баланс: 356574.61. За год 176574.61 / 8%
+Баланс: 391827.22. За год 201827.22 / 8%
+Баланс: 2258726.72. За год 2058726.72 / -31%
+Баланс: 198574.3. За год -321425.7 / 5%
+Баланс: -157643.28. За год -687643.28 / -2%
+Баланс: -275896.54. За год -815896.54 / -5%
+Баланс: -327767.76. За год -877767.76 / -6%
+Баланс: -356576.72. За год -916576.72 / -7%
+Баланс: -368078.48. За год -938078.48 / -7%
+Баланс: -372792.53. За год -952792.53 / -7%
+Баланс: -369238.51. За год -959238.51 / -7%
+Баланс: -352196.67. За год -952196.67 / -7%
+Баланс: -294213.53. За год -904213.53 / -5%
+Баланс: 44865.48. За год -575134.52 / 2%
+Максимальный доход 0 начался с 0

+ 71 - 1
PM02/Program.cs

@@ -1,15 +1,85 @@
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
 namespace PM02
 {
-    internal class Program
+    public class Program
     {
         static void Main(string[] args)
         {
+            TextWriterTraceListener tr2 = new TextWriterTraceListener(System.IO.File.CreateText(@"../../Output.txt"));
+            Debug.Listeners.Add(tr2);
+            Dictionary<double,double> money = new Dictionary<double, double>();
+            for (int i = 0; i <= 1000000; i+= 10000)
+            {
+                User user = new User();
+                double percentBet = 1;
+                double bankBet = 8;
+                user.investment = i;
+                user.deposit = user.investment;
+                double currentDeposit = user.investment;
+                double monthIncome = 0;
+                double yearIncome = 0;
+                int month = 1;
+                int year = 2022;
+                while (currentDeposit < 1000000)
+                {
+                    if (percentBet > bankBet)
+                        currentDeposit *= percentBet;
+
+                    if (currentDeposit < 700000)
+                    {
+                        percentBet = Math.Round(currentDeposit) / 50000 + 1;
+                    }
+                    else
+                    {
+                        int tmp = (int)currentDeposit - 700000;
+                        percentBet = 20 - tmp / 50000;
+                    }
+                    if (currentDeposit == 700000)
+                        percentBet = 20;
+                    if (month % 3 == 0)
+                        IncreaseBet(percentBet, 0.5);
+
+                    currentDeposit += currentDeposit * (percentBet / 100);
+                    monthIncome = currentDeposit - user.deposit;
+                    if (percentBet > bankBet && percentBet - bankBet >= 5)
+                        currentDeposit -= GetTax(monthIncome);
+                    month++;
+                    Console.WriteLine("Баланс: {0} / {1}%", Math.Round(currentDeposit, 2), Math.Round(percentBet));
+                    if (month == 13)
+                    {
+                        yearIncome = currentDeposit - user.deposit;
+                        month = 0;
+                        year++;
+                        Debug.WriteLine("Баланс: {0}. За год {1} / {2}%", Math.Round(currentDeposit, 2), Math.Round(yearIncome, 2), Math.Round(percentBet));
+                        user.deposit = currentDeposit;
+                        
+                        break;
+                    }
+                }
+                money.Add(user.investment,currentDeposit);
+            }
+            foreach (var item in money.OrderByDescending(value => value.Value))
+            {
+
+            }
+            Debug.WriteLine($"Максимальный доход {money.Keys.First()} начался с {money.Values.First()}");
+            Debug.Flush();
+            Console.ReadLine();
         }
+        static double IncreaseBet(double bet, double count) => bet += count;
+        public static double GetTax(double deposit) => deposit *= 0.0;
+    }
+
+    public class User
+    {
+        public double investment { get; set; }
+        public double deposit { get; set; }
+        public double bet { get; set; }
     }
 }

+ 20 - 0
UnitTest/Properties/AssemblyInfo.cs

@@ -0,0 +1,20 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("UnitTest")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("UnitTest")]
+[assembly: AssemblyCopyright("Copyright ©  2022")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("058a4617-618c-47a0-b030-5529b486b119")]
+
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 74 - 0
UnitTest/UnitTest.csproj

@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.props')" />
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{058A4617-618C-47A0-B030-5529B486B119}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>UnitTest</RootNamespace>
+    <AssemblyName>UnitTest</AssemblyName>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
+    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
+    <IsCodedUITest>False</IsCodedUITest>
+    <TestProjectType>UnitTest</TestProjectType>
+    <NuGetPackageImportStamp>
+    </NuGetPackageImportStamp>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MSTest.TestFramework.2.2.7\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MSTest.TestFramework.2.2.7\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="UnitTest1.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\PM02\PM02.csproj">
+      <Project>{517871a9-aaac-4081-a925-c87d8c720ef4}</Project>
+      <Name>PM02</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их.  Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.props'))" />
+    <Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.targets'))" />
+  </Target>
+  <Import Project="..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.targets')" />
+</Project>

+ 26 - 0
UnitTest/UnitTest1.cs

@@ -0,0 +1,26 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+
+namespace UnitTest
+{
+    [TestClass]
+    public class UnitTest1
+    {
+        [TestMethod]
+        public void _30_percent_from_50000_equal_15000()
+        {
+            int tax = 30;
+            double actual, expected = 50000 * 0.3;
+            actual = PM02.Program.GetTax(50000);
+            Assert.AreEqual(expected, actual);
+        }
+        [TestMethod]
+        public void _30_percent_from_50000_equal_35000()
+        {
+            int tax = 30;
+            double actual, expected = 50000 * 0.6;
+            actual = PM02.Program.GetTax(50000);
+            Assert.AreEqual(expected, actual);
+        }
+    }
+}

+ 5 - 0
UnitTest/packages.config

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MSTest.TestAdapter" version="2.2.7" targetFramework="net472" />
+  <package id="MSTest.TestFramework" version="2.2.7" targetFramework="net472" />
+</packages>