From cfe37b3d429272b2cc1a32deb0860a77bc2f3fa9 Mon Sep 17 00:00:00 2001 From: Timourka Date: Mon, 6 Nov 2023 17:14:14 +0400 Subject: [PATCH] =?UTF-8?q?=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=83=D0=BD=D0=BA=D1=82=D0=B0=206?= =?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D1=8B=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Laba1Loco/Laba1Loco/DrawingLoco.cs | 4 ---- Laba1Loco/Laba1Loco/DrawingTrain.cs | 4 ---- Laba1Loco/Laba1Loco/EntityLoco.cs | 5 ++++- Laba1Loco/Laba1Loco/EntityTrain.cs | 5 ++++- Laba1Loco/Laba1Loco/FormTrainConfig.cs | 4 ++-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Laba1Loco/Laba1Loco/DrawingLoco.cs b/Laba1Loco/Laba1Loco/DrawingLoco.cs index 724d851..f751475 100644 --- a/Laba1Loco/Laba1Loco/DrawingLoco.cs +++ b/Laba1Loco/Laba1Loco/DrawingLoco.cs @@ -10,10 +10,6 @@ namespace Laba1Loco { internal class DrawingLoco : DrawingTrain { - public void setAdditionalColor(Color color) - { - (EntityTrain as EntityLoco).AdditionalColor = color; - } /// /// Инициализация свойств /// diff --git a/Laba1Loco/Laba1Loco/DrawingTrain.cs b/Laba1Loco/Laba1Loco/DrawingTrain.cs index 58d9019..8622934 100644 --- a/Laba1Loco/Laba1Loco/DrawingTrain.cs +++ b/Laba1Loco/Laba1Loco/DrawingTrain.cs @@ -10,10 +10,6 @@ namespace Laba1Loco { internal class DrawingTrain { - public void setBodyColor(Color color) - { - EntityTrain.BodyColor = color; - } public IMoveableObject GetMoveableObject => new DrawningObjectTrain(this); /// /// Класс-сущность diff --git a/Laba1Loco/Laba1Loco/EntityLoco.cs b/Laba1Loco/Laba1Loco/EntityLoco.cs index 82c9e3d..0017528 100644 --- a/Laba1Loco/Laba1Loco/EntityLoco.cs +++ b/Laba1Loco/Laba1Loco/EntityLoco.cs @@ -9,7 +9,10 @@ namespace Laba1Loco { internal class EntityLoco : EntityTrain { - public Color AdditionalColor { get; set; } + public Color AdditionalColor { get; private set; } + + public void setAdditionalColor(Color color) { AdditionalColor = color; } + /// /// Признак (опция) наличия трубы /// diff --git a/Laba1Loco/Laba1Loco/EntityTrain.cs b/Laba1Loco/Laba1Loco/EntityTrain.cs index c64210a..c945fe5 100644 --- a/Laba1Loco/Laba1Loco/EntityTrain.cs +++ b/Laba1Loco/Laba1Loco/EntityTrain.cs @@ -20,7 +20,10 @@ namespace Laba1Loco /// /// Основной цвет /// - public Color BodyColor { get; set; } + public Color BodyColor { get; private set; } + + public void setBodyColor(Color color) { BodyColor = color; } + /// /// Шаг перемещения поезда /// diff --git a/Laba1Loco/Laba1Loco/FormTrainConfig.cs b/Laba1Loco/Laba1Loco/FormTrainConfig.cs index c98a240..a0ac287 100644 --- a/Laba1Loco/Laba1Loco/FormTrainConfig.cs +++ b/Laba1Loco/Laba1Loco/FormTrainConfig.cs @@ -140,12 +140,12 @@ namespace Laba1Loco switch (((Label)sender).Name) { case "labelColor": - _train.setBodyColor((Color)e.Data.GetData(typeof(Color))); + _train.EntityTrain.setBodyColor((Color)e.Data.GetData(typeof(Color))); break; case "labelAdditionalColor": if (!(_train is DrawingLoco)) return; - (_train as DrawingLoco).setAdditionalColor((Color)e.Data.GetData(typeof(Color))); + (_train.EntityTrain as EntityLoco).setAdditionalColor((Color)e.Data.GetData(typeof(Color))); break; } DrawTrain();