From c0b10d25c29a0ba06afc8621b9727eca2f674322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=93=D0=BE=D1=80=D0=B4?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2?= <89176335310x@gmail.com> Date: Fri, 17 Nov 2023 12:37:16 +0400 Subject: [PATCH] Sdano --- .../ElectricLocomotive/DrawningElectricLocomotive.cs | 2 +- .../ElectricLocomotive/DrawningLocomotive.cs | 10 +++++----- .../ElectricLocomotive/ElectricLocomotive.cs | 5 +---- .../ElectricLocomotive/EntityElectricLocomotive.cs | 5 ++++- .../ElectricLocomotive/EntityLocomotive.cs | 7 +------ 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs index a9aa508..17d3263 100644 --- a/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/DrawningElectricLocomotive.cs @@ -11,7 +11,7 @@ namespace ElectricLocomotive public class DrawningElectricLocomotive : DrawningLocomotive { public DrawningElectricLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool Horns, int width, int height) - : base (speed, weight, bodyColor, additionalColor, width , height) + : base (speed, weight, bodyColor, width , height) { if (EntityLocomotive != null) { diff --git a/ElectricLocomotive/ElectricLocomotive/DrawningLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/DrawningLocomotive.cs index 9e06681..ef15a0e 100644 --- a/ElectricLocomotive/ElectricLocomotive/DrawningLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/DrawningLocomotive.cs @@ -31,7 +31,7 @@ namespace ElectricLocomotive.DrawningObject public int GetWidth => _locoWidth; public int GetHeight => _locoHeight; - public DrawningLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, int width, int heigth) + public DrawningLocomotive(int speed, double weight, Color bodyColor, int width, int heigth) { if (width < _locoWidth || heigth < _locoHeight) { @@ -39,7 +39,7 @@ namespace ElectricLocomotive.DrawningObject } _pictureWidth = width; _pictureHeight = heigth; - EntityLocomotive = new EntityLocomotive(speed, weight, bodyColor, additionalColor); + EntityLocomotive = new EntityLocomotive(speed, weight, bodyColor); } protected DrawningLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, int width, @@ -53,7 +53,7 @@ namespace ElectricLocomotive.DrawningObject _pictureHeight = height; _locoWidth = locoWidth; _locoHeight = locoHeight; - EntityLocomotive = new EntityLocomotive(speed, weight, bodyColor, additionalColor); + EntityLocomotive = new EntityLocomotive(speed, weight, bodyColor); } /// /// Установка позиции @@ -124,8 +124,8 @@ namespace ElectricLocomotive.DrawningObject { return; } - Pen pen = new(EntityLocomotive.BodyColor); - Brush brush = new SolidBrush(EntityLocomotive.AdditionalColor); + Pen pen = new(Color.Black); + Brush brush = new SolidBrush(EntityLocomotive.BodyColor); ///ВЛ60к-1595 ///ходовая diff --git a/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs index fd5cab7..108187d 100644 --- a/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/ElectricLocomotive.cs @@ -36,11 +36,10 @@ namespace ElectricLocomotive { Random random = new(); Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); - Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); ColorDialog dialog = new(); if (dialog.ShowDialog() == DialogResult.OK) color = dialog.Color; - _drawningLocomotive = new DrawningLocomotive(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, pictureBoxElectroLocomotiv.Width, pictureBoxElectroLocomotiv.Height); + _drawningLocomotive = new DrawningLocomotive(random.Next(100, 300), random.Next(1000, 3000), color, pictureBoxElectroLocomotiv.Width, pictureBoxElectroLocomotiv.Height); _drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); @@ -51,14 +50,12 @@ namespace ElectricLocomotive Random random = new(); Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); - Color batteryColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); bool Horns = Convert.ToBoolean(random.Next(0, 2)); ColorDialog dialog = new(); if (dialog.ShowDialog() == DialogResult.OK) color = dialog.Color; if (dialog.ShowDialog() == DialogResult.OK) dopColor = dialog.Color; - _drawningLocomotive = new DrawningElectricLocomotive(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, Horns, pictureBoxElectroLocomotiv.Width, pictureBoxElectroLocomotiv.Height); _drawningLocomotive.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); diff --git a/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs index a340c0f..df3aeb2 100644 --- a/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/EntityElectricLocomotive.cs @@ -9,12 +9,15 @@ namespace ElectricLocomotive.Entities { public class EntityElectroLocomotive : EntityLocomotive { + public Color AdditionalColor { get; private set; } + public bool Horns { get; private set; } /// /// Признак (опция) roga /// - public EntityElectroLocomotive(int Speed, double weight, Color bodyColor, Color additionalColor, bool horns) : base(Speed,weight,bodyColor, additionalColor) + public EntityElectroLocomotive(int Speed, double weight, Color bodyColor, Color additionalColor, bool horns) : base(Speed,weight,bodyColor) { + AdditionalColor = additionalColor; Horns = horns; } } diff --git a/ElectricLocomotive/ElectricLocomotive/EntityLocomotive.cs b/ElectricLocomotive/ElectricLocomotive/EntityLocomotive.cs index 550fa55..9e45f19 100644 --- a/ElectricLocomotive/ElectricLocomotive/EntityLocomotive.cs +++ b/ElectricLocomotive/ElectricLocomotive/EntityLocomotive.cs @@ -21,10 +21,6 @@ namespace ElectricLocomotive.Entities /// public Color BodyColor { get; private set; } /// - /// Дополнительный цвет (для опциональных элементов) - /// - public Color AdditionalColor { get; private set; } - /// /// Признак (опция) наличия обвеса /// public double Step => (double)Speed * 100 / Weight; @@ -34,12 +30,11 @@ namespace ElectricLocomotive.Entities /// Скорость /// Вес автомобиля /// Основной цвет - public EntityLocomotive(int speed, double weight, Color bodyColor, Color additionalColor) + public EntityLocomotive(int speed, double weight, Color bodyColor) { Speed = speed; Weight = weight; BodyColor = bodyColor; - AdditionalColor = additionalColor; } } }