From 5ac338e3788e60eb69740e334893df6ef4e3556e Mon Sep 17 00:00:00 2001 From: "a.puchkina" Date: Wed, 25 Oct 2023 14:20:24 +0400 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=B1=D1=80=D0=B0=D0=BB=D0=B0=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BF=20=D1=86=D0=B2=D0=B5=D1=82=20=D0=B8=D0=B7=20=D0=B1?= =?UTF-8?q?=D0=B0=D0=B7=D0=BE=D0=B2=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=BB=D0=B0?= =?UTF-8?q?=D1=81=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AirplaneWithRadar/AirplaneWithRadarForm.cs | 8 +------- .../AirplaneWithRadar/DrawningAirplane.cs | 16 ++++++---------- .../DrawningAirplaneWithRadar.cs | 5 ++--- .../AirplaneWithRadar/EntityAirplane.cs | 9 +-------- .../AirplaneWithRadar/EntityAirplaneWithRadar.cs | 9 +++++++-- 5 files changed, 17 insertions(+), 30 deletions(-) diff --git a/AirplaneWithRadar/AirplaneWithRadar/AirplaneWithRadarForm.cs b/AirplaneWithRadar/AirplaneWithRadar/AirplaneWithRadarForm.cs index 35566e4..02fbcbe 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/AirplaneWithRadarForm.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/AirplaneWithRadarForm.cs @@ -67,14 +67,8 @@ namespace AirplaneWithRadar { bodyColor = dialog.Color; } - Color additionalColor = Color.FromArgb(random.Next(0, 256), - random.Next(0, 256), random.Next(0, 256)); - if (dialog.ShowDialog() == DialogResult.OK) - { - additionalColor = dialog.Color; - } _drawningAirplane = new DrawningAirplane(random.Next(100, 300), random.Next(1000, 3000), - bodyColor, additionalColor, + bodyColor, pictureBoxAirplane.Width, pictureBoxAirplane.Height); _drawningAirplane.SetPosition(random.Next(10, 100), random.Next(10, 100)); diff --git a/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplane.cs index 1729e2c..08e9c39 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplane.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplane.cs @@ -52,12 +52,10 @@ namespace AirplaneWithRadar.DrawningObjects /// Скорость /// Вес /// Цвет фюзеляжа - /// Дополнительный цвет /// Ширина картинки /// Высота картинки /// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах - public DrawningAirplane(int speed, double weight, Color bodyColor, Color - additionalColor, int width, int height) + public DrawningAirplane(int speed, double weight, Color bodyColor, int width, int height) { _pictureWidth = width; _pictureHeight = height; @@ -65,8 +63,7 @@ namespace AirplaneWithRadar.DrawningObjects { return; } - EntityAirplane = new EntityAirplane(speed, weight, bodyColor, - additionalColor); + EntityAirplane = new EntityAirplane(speed, weight, bodyColor); } /// /// Конструктор @@ -78,7 +75,7 @@ namespace AirplaneWithRadar.DrawningObjects /// Высота картинки /// Ширина прорисовки автомобиля /// Высота прорисовки автомобиля - protected DrawningAirplane(int speed, double weight, Color bodyColor, Color additionalColor, int + protected DrawningAirplane(int speed, double weight, Color bodyColor, int width, int height, int airplaneWidth, int airplaneHeight) { _pictureWidth = width; @@ -89,7 +86,7 @@ namespace AirplaneWithRadar.DrawningObjects { return; } - EntityAirplane = new EntityAirplane(speed, weight, bodyColor, additionalColor); + EntityAirplane = new EntityAirplane(speed, weight, bodyColor); } /// /// Установка позиции @@ -194,7 +191,6 @@ namespace AirplaneWithRadar.DrawningObjects return; } Pen penBlack = new(Color.Black); - Brush additionalBrush = new SolidBrush(EntityAirplane.AdditionalColor); Brush bodyBrush = new SolidBrush(EntityAirplane.BodyColor); //фюзеляж @@ -202,7 +198,7 @@ namespace AirplaneWithRadar.DrawningObjects g.DrawRectangle(penBlack, _startPosX + 4, _startPosY + 40, 150, 30); //киль - g.FillPolygon(additionalBrush, new Point[] { new Point(_startPosX + 4, _startPosY + 40), new Point(_startPosX + 4, _startPosY + 0), new Point(_startPosX + 50, _startPosY + 40) }); + g.FillPolygon(bodyBrush, new Point[] { new Point(_startPosX + 4, _startPosY + 40), new Point(_startPosX + 4, _startPosY + 0), new Point(_startPosX + 50, _startPosY + 40) }); g.DrawPolygon(penBlack, new Point[] { new Point(_startPosX + 4, _startPosY + 40), new Point(_startPosX + 4, _startPosY + 0), new Point(_startPosX + 50, _startPosY + 40) }); //стабилизатор и крыло @@ -225,7 +221,7 @@ namespace AirplaneWithRadar.DrawningObjects //кабина Brush brLightBlue = new SolidBrush(Color.LightBlue); Pen penBlue = new Pen(Color.CadetBlue); - g.FillPolygon(additionalBrush, new Point[] { new Point(_startPosX + 150, _startPosY + 55), new Point(_startPosX + 190, _startPosY + 55), new Point(_startPosX + 150, _startPosY + 72) }); + g.FillPolygon(bodyBrush, new Point[] { new Point(_startPosX + 150, _startPosY + 55), new Point(_startPosX + 190, _startPosY + 55), new Point(_startPosX + 150, _startPosY + 72) }); g.FillPolygon(brLightBlue, new Point[] { new Point(_startPosX + 150, _startPosY + 55), new Point(_startPosX + 150, _startPosY + 38), new Point(_startPosX + 190, _startPosY + 55) }); g.DrawLine(penBlack, new Point(_startPosX + 150, _startPosY + 55), new Point(_startPosX + 150, _startPosY + 38)); g.DrawLine(penBlack, new Point(_startPosX + 150, _startPosY + 38), new Point(_startPosX + 190, _startPosY + 55)); diff --git a/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplaneWithRadar.cs b/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplaneWithRadar.cs index 79b37ce..59b75b9 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplaneWithRadar.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/DrawningAirplaneWithRadar.cs @@ -24,7 +24,7 @@ namespace AirplaneWithRadar.DrawningObjects /// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах public DrawningAirplaneWithRadar(int speed, double weight, Color bodyColor, Color additionalColor, bool radar, bool tank, bool pin, int width, int height) : - base(speed, weight, bodyColor, additionalolor, width, height) + base(speed, weight, bodyColor, width, height, 200, 85) { if (EntityAirplane != null) { @@ -39,8 +39,7 @@ namespace AirplaneWithRadar.DrawningObjects return; } Pen penBlack = new(Color.Black); - Brush additionalBrush = new SolidBrush(EntityAirplane.AdditionalColor); - Brush bodyBrush = new SolidBrush(EntityAirplane.BodyColor); + Brush additionalBrush = new SolidBrush(airplaneWithRadar.AdditionalColor); Pen penGray = new Pen(Color.Gray); // радар diff --git a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs index 6eb305a..4791138 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplane.cs @@ -24,10 +24,6 @@ namespace AirplaneWithRadar.Entities /// public Color BodyColor { get; private set; } /// - /// Дополнительный цвет (для опциональных элементов) - /// - public Color AdditionalColor { get; private set; } - /// /// Шаг перемещения самолета /// public double Step => (double)Speed * 100 / Weight; @@ -37,14 +33,11 @@ namespace AirplaneWithRadar.Entities /// Скорость /// Вес самолета /// Основной цвет - /// Дополнительный цвет - public EntityAirplane(int speed, double weight, Color bodyColor, Color - additionalColor) + public EntityAirplane(int speed, double weight, Color bodyColor) { Speed = speed; Weight = weight; BodyColor = bodyColor; - AdditionalColor = additionalColor; } } diff --git a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs index b676ebe..6ded1b0 100644 --- a/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs +++ b/AirplaneWithRadar/AirplaneWithRadar/EntityAirplaneWithRadar.cs @@ -11,6 +11,10 @@ namespace AirplaneWithRadar.Entities /// public class EntityAirplaneWithRadar : EntityAirplane { + /// + /// Дополнительный цвет (для опциональных элементов) + /// + public Color AdditionalColor { get; private set; } /// /// Признак (опция) наличия радара /// @@ -33,9 +37,10 @@ namespace AirplaneWithRadar.Entities /// Признак наличия радара /// Признак наличия доп.бака /// Признак наличия штыря - public EntityAirplaneWithRadar(int speed, double weight, Color bodyColor, Color - additionalColor, bool radar, bool tank, bool pin) : base (speed, weight, bodyColor) + public EntityAirplaneWithRadar(int speed, double weight, Color bodyColor, + Color additionalColor, bool radar, bool tank, bool pin) : base (speed, weight, bodyColor) { + AdditionalColor = additionalColor; Radar = radar; Tank = tank; Pin = pin;