From a0f64e592fa34523161fba7d0bba2ff1a8f64b7a Mon Sep 17 00:00:00 2001 From: F1rsTTeaM Date: Sat, 23 Mar 2024 15:11:25 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=B0=D0=BF=D0=BA=D0=B8=20Entities?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrawingAirplaneWithRadar.cs | 22 ++++----- .../Entities/EntityAirplane.cs | 48 +++++++++++++++++++ .../{ => Entities}/EntityAirplaneWithRadar.cs | 35 +++----------- .../FormAirplaneWithRadar.cs | 4 +- 4 files changed, 68 insertions(+), 41 deletions(-) create mode 100644 AirplaneWithRadar/ProjectAirplaneWithRadar/Entities/EntityAirplane.cs rename AirplaneWithRadar/ProjectAirplaneWithRadar/{ => Entities}/EntityAirplaneWithRadar.cs (56%) diff --git a/AirplaneWithRadar/ProjectAirplaneWithRadar/DrawingAirplaneWithRadar.cs b/AirplaneWithRadar/ProjectAirplaneWithRadar/DrawingAirplaneWithRadar.cs index 59761f7..36f61b6 100644 --- a/AirplaneWithRadar/ProjectAirplaneWithRadar/DrawingAirplaneWithRadar.cs +++ b/AirplaneWithRadar/ProjectAirplaneWithRadar/DrawingAirplaneWithRadar.cs @@ -1,4 +1,4 @@ -namespace ProjectAirplaneWithRadar +namespace ProjectAirplaneWithRadar.Entities { /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности @@ -39,7 +39,7 @@ /// Высота прорисовки самолета /// public readonly int PlaneHeight = 95; - + /// /// Инициализация свойств @@ -72,18 +72,18 @@ { _pictureWidth = width; _pictureHeight = height; - if(_startPosX != null && _startPosY != null) + if (_startPosX != null && _startPosY != null) { - if(_startPosX.Value < 0) + if (_startPosX.Value < 0) { _startPosX = 0; } - if(_startPosY.Value < 0) + if (_startPosY.Value < 0) { _startPosY = 0; } - if(_startPosX.Value + PlaneWidth > _pictureWidth) + if (_startPosX.Value + PlaneWidth > _pictureWidth) { _startPosX = _pictureWidth - PlaneWidth; } @@ -116,7 +116,7 @@ { _startPosX = 0; } - if(_startPosY.Value < 0) + if (_startPosY.Value < 0) { _startPosY = 0; } @@ -162,7 +162,7 @@ break; // вправо case DirectionType.Right: - if (_startPosX.Value + step < _pictureWidth - PlaneWidth) + if (_startPosX.Value + step < _pictureWidth - PlaneWidth) { _startPosX += step; } @@ -227,8 +227,8 @@ } //Корпус - g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 50,100,30); - + g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 50, 100, 30); + //Хвост Point[] points = { new Point(_startPosX.Value + 10, _startPosY.Value + 10), @@ -259,7 +259,7 @@ //Хвостовой элерон g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 45, 30, 10); g.FillEllipse(brBlack, _startPosX.Value, _startPosY.Value + 45, 30, 10); - + } } } diff --git a/AirplaneWithRadar/ProjectAirplaneWithRadar/Entities/EntityAirplane.cs b/AirplaneWithRadar/ProjectAirplaneWithRadar/Entities/EntityAirplane.cs new file mode 100644 index 0000000..868b609 --- /dev/null +++ b/AirplaneWithRadar/ProjectAirplaneWithRadar/Entities/EntityAirplane.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace ProjectAirplaneWithRadar.Entities +{ + /// + /// Класс-сущность "Самолет" + /// + public class EntityAirplane + { + /// + /// Скорость + /// + public int Speed { get; private set; } + + /// + /// Вес + /// + public double Weight { get; private set; } + + /// + /// Основной цвет + /// + public Color BodyColor { get; private set; } + + /// + /// Шаг перемещения автомобиля + /// + public double Step => Speed * 100 / Weight; + + /// + /// Конструктор сущности + /// + /// Скорость + /// Вес + /// Основной цвет + public EntityAirplane(int speed, double weight, Color bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + } + } +} \ No newline at end of file diff --git a/AirplaneWithRadar/ProjectAirplaneWithRadar/EntityAirplaneWithRadar.cs b/AirplaneWithRadar/ProjectAirplaneWithRadar/Entities/EntityAirplaneWithRadar.cs similarity index 56% rename from AirplaneWithRadar/ProjectAirplaneWithRadar/EntityAirplaneWithRadar.cs rename to AirplaneWithRadar/ProjectAirplaneWithRadar/Entities/EntityAirplaneWithRadar.cs index 598eda9..269b5ed 100644 --- a/AirplaneWithRadar/ProjectAirplaneWithRadar/EntityAirplaneWithRadar.cs +++ b/AirplaneWithRadar/ProjectAirplaneWithRadar/Entities/EntityAirplaneWithRadar.cs @@ -1,25 +1,10 @@ -namespace ProjectAirplaneWithRadar +namespace ProjectAirplaneWithRadar.Entities { /// /// Класс-сущность "Самолет с радаром" /// - public class EntityAirplaneWithRadar + public class EntityAirplaneWithRadar : EntityAirplane { - /// - /// Скорость - /// - public int Speed { get; private set; } - - /// - /// Вес - /// - public double Weight { get; private set; } - - /// - /// Основной цвет - /// - public Color BodyColor { get; private set; } - /// /// Дополнительный цвет (для опциональных элементов) /// @@ -33,12 +18,7 @@ /// /// Признак (опция) наличия радар /// - public bool Radar { get; private set; } - - /// - /// Шаг перемещения автомобиля - /// - public double Step => Speed * 100 / Weight; + public bool Radar { get; private set; } /// /// Инициализация полей объекта-класса самолета с радаром @@ -49,14 +29,11 @@ /// Дополнительный цвет /// Шасси /// Радар - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool wheels, bool radar) - { - Speed = speed; - Weight = weight; - BodyColor = bodyColor; + public EntityAirplaneWithRadar(int speed, double weight, Color bodyColor, Color additionalColor, bool wheels, bool radar) : base(speed, weight, bodyColor) + { AdditionalColor = additionalColor; Wheels = wheels; - Radar = radar; + Radar = radar; } } } diff --git a/AirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneWithRadar.cs b/AirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneWithRadar.cs index 7ec64fb..2b353ba 100644 --- a/AirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneWithRadar.cs +++ b/AirplaneWithRadar/ProjectAirplaneWithRadar/FormAirplaneWithRadar.cs @@ -1,4 +1,6 @@ -namespace ProjectAirplaneWithRadar +using ProjectAirplaneWithRadar.Entities; + +namespace ProjectAirplaneWithRadar { /// /// Форма работы с объектом "Самолет с радаром"