Alec vor 3 Jahren
Ursprung
Commit
ba1f6c7bb4
8 geänderte Dateien mit 239 neuen und 0 gelöschten Zeilen
  1. 6 0
      Vehicle/App.config
  2. 19 0
      Vehicle/Bike.cs
  3. 19 0
      Vehicle/Car.cs
  4. 28 0
      Vehicle/Program.cs
  5. 36 0
      Vehicle/Properties/AssemblyInfo.cs
  6. 50 0
      Vehicle/Vehicle.cs
  7. 56 0
      Vehicle/Vehicle.csproj
  8. 25 0
      Vehicle/Vehicle.sln

+ 6 - 0
Vehicle/App.config

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+    <startup> 
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
+    </startup>
+</configuration>

+ 19 - 0
Vehicle/Bike.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Vehicle
+{
+    class Bike : Vehicle
+    {
+        public Bike(string manufacture, string model, string color, float ec)
+        {
+            Manufacturer = manufacture;
+            Model = model;
+            Color = color;
+            EngineСapacity = ec;
+        }
+    }
+}

+ 19 - 0
Vehicle/Car.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Vehicle
+{
+    class Car : Vehicle
+    {
+        public Car(string manufacture, string model, string color, float ec)
+        {
+            Manufacturer = manufacture;
+            Model = model;
+            Color = color;
+            EngineСapacity = ec;
+        }
+    }
+}

+ 28 - 0
Vehicle/Program.cs

@@ -0,0 +1,28 @@
+using System;
+
+namespace Vehicle
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            Vehicle[] vehicle = new Vehicle[5];
+
+            vehicle[0] = new Car("Nissan", "GT-R", "Blue", 3.2f);
+            vehicle[1] = new Car("Toyota", "Supra", "White", 3.6f);
+            vehicle[2] = new Bike("Yamaha", "???", "Red", 2.4f);
+            vehicle[3] = new Car("Opel", "Astra", "Yellow", 2.5f);
+            vehicle[4] = new Bike("Kawasaki", "Ninja", "Green", 4.1f);
+
+            foreach (Vehicle v in vehicle)
+            {
+                v.FuelUp(10.0f);
+            }
+
+            vehicle[3].Move(2343);
+            vehicle[0].Move(4770);
+
+            Console.ReadKey();
+        }
+    }
+}

+ 36 - 0
Vehicle/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Общие сведения об этой сборке предоставляются следующим набором
+// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
+// связанные со сборкой.
+[assembly: AssemblyTitle("Vehicle")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Vehicle")]
+[assembly: AssemblyCopyright("Copyright ©  2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
+// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
+// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
+[assembly: ComVisible(false)]
+
+// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
+[assembly: Guid("37e58a08-0ce6-4ce6-ad79-2a37bcb7b9de")]
+
+// Сведения о версии сборки состоят из следующих четырех значений:
+//
+//      Основной номер версии
+//      Дополнительный номер версии
+//   Номер сборки
+//      Редакция
+//
+// Можно задать все значения или принять номер сборки и номер редакции по умолчанию.
+// используя "*", как показано ниже:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 50 - 0
Vehicle/Vehicle.cs

@@ -0,0 +1,50 @@
+using System;
+
+namespace Vehicle
+{
+    class Vehicle
+    {
+        protected string Model;
+        protected string Manufacturer;
+        protected string Color;
+
+        // Объем двигателя (2,5)
+        protected float EngineСapacity;
+        // Горючее
+        protected float Fuel;
+        // Мощьность л/с
+        protected int Power;
+        // Пройденный путь
+        protected int Distance;
+
+        //                      4770
+        public void Move(int distance)
+        {
+            if (distance < 1)
+            {
+                return;
+            }
+            float DeltaFuel = EngineСapacity * 0.01f;
+            int currentDistance = 0;
+            while (currentDistance < distance)
+            {
+                // 0,1      0,125
+                if (Fuel < DeltaFuel)
+                {
+                    Console.WriteLine("Закончилось горючее у " + Manufacturer + " " + Model);
+                    break;
+                }
+                Fuel -= DeltaFuel;
+                Distance++;
+                currentDistance++;
+            }
+
+            Console.WriteLine(Manufacturer + " " + Model + " проехал " + currentDistance + " метров из " + distance);
+        }
+
+        public void FuelUp(float value)
+        {
+            Fuel += value;
+        }
+    }
+}

+ 56 - 0
Vehicle/Vehicle.csproj

@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <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>{37E58A08-0CE6-4CE6-AD79-2A37BCB7B9DE}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>Vehicle</RootNamespace>
+    <AssemblyName>Vehicle</AssemblyName>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <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' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Bike.cs" />
+    <Compile Include="Car.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Vehicle.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 25 - 0
Vehicle/Vehicle.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.1267
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vehicle", "Vehicle.csproj", "{37E58A08-0CE6-4CE6-AD79-2A37BCB7B9DE}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{37E58A08-0CE6-4CE6-AD79-2A37BCB7B9DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{37E58A08-0CE6-4CE6-AD79-2A37BCB7B9DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{37E58A08-0CE6-4CE6-AD79-2A37BCB7B9DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{37E58A08-0CE6-4CE6-AD79-2A37BCB7B9DE}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {A87C2102-22E0-40F6-8F09-FCA59AB0C934}
+	EndGlobalSection
+EndGlobal