функция для пункта 6 лабы 5

This commit is contained in:
Timourka 2023-11-06 17:14:14 +04:00
parent 8cf45a8ea4
commit cfe37b3d42
5 changed files with 10 additions and 12 deletions

View File

@ -10,10 +10,6 @@ namespace Laba1Loco
{
internal class DrawingLoco : DrawingTrain
{
public void setAdditionalColor(Color color)
{
(EntityTrain as EntityLoco).AdditionalColor = color;
}
/// <summary>
/// Инициализация свойств
/// </summary>

View File

@ -10,10 +10,6 @@ namespace Laba1Loco
{
internal class DrawingTrain
{
public void setBodyColor(Color color)
{
EntityTrain.BodyColor = color;
}
public IMoveableObject GetMoveableObject => new DrawningObjectTrain(this);
/// <summary>
/// Класс-сущность

View File

@ -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; }
/// <summary>
/// Признак (опция) наличия трубы
/// </summary>

View File

@ -20,7 +20,10 @@ namespace Laba1Loco
/// <summary>
/// Основной цвет
/// </summary>
public Color BodyColor { get; set; }
public Color BodyColor { get; private set; }
public void setBodyColor(Color color) { BodyColor = color; }
/// <summary>
/// Шаг перемещения поезда
/// </summary>

View File

@ -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();