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

This commit is contained in:
Timourka 2023-11-06 17:23:00 +04:00
parent 789fe7165d
commit 1a6dcf7059
5 changed files with 6 additions and 12 deletions

View File

@ -8,11 +8,6 @@ import java.awt.event.*;
public class DrawingLoco extends DrawingTrain{
public void setAdditionalColor(Color color)
{
((EntityLoco)EntityTrain).AdditionalColor = color;
}
/// <summary>
/// Инициализация свойств
/// </summary>

View File

@ -9,11 +9,6 @@ import java.awt.event.*;
public class DrawingTrain {
public IMoveableObject GetMoveableObject() { return new DrawningObjectTrain(this);}
public void setBodyColor(Color color)
{
EntityTrain.BodyColor = color;
}
protected IWheelDrawing wheelDrawing;
/// <summary>
/// Класс-сущность

View File

@ -8,6 +8,8 @@ import java.awt.event.*;
public class EntityLoco extends EntityTrain{
public Color AdditionalColor;
public void setAdditionalColor(Color color){AdditionalColor = color;}
/// <summary>
/// Признак (опция) наличия трубы
/// </summary>

View File

@ -19,6 +19,8 @@ public class EntityTrain {
/// Основной цвет
/// </summary>
public Color BodyColor;
public void setBodyColor(Color color){BodyColor = color;}
/// <summary>
/// Шаг перемещения поезда
/// </summary>

View File

@ -230,7 +230,7 @@ public class FormTrainConfig {
Color color = (Color) support.getTransferable().getTransferData(ColorTransferable.colorDataFlavor);
if (_train == null)
return false;
_train.setBodyColor(color);
_train.EntityTrain.setBodyColor(color);
canvas.repaint();
return true;
} catch (UnsupportedFlavorException | IOException e) {
@ -262,7 +262,7 @@ public class FormTrainConfig {
return false;
if (!(_train instanceof DrawingLoco))
return false;
((DrawingLoco)_train).setAdditionalColor(color);
((EntityLoco)_train.EntityTrain).setAdditionalColor(color);
return true;
} catch (UnsupportedFlavorException | IOException e) {
e.printStackTrace();