75 lines
3.0 KiB
C#
75 lines
3.0 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel.Design;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace ProjectElectricLocomotive.Entities
|
||
{
|
||
public class EntityElectricLocomotive : EntityLocomotive
|
||
{
|
||
|
||
|
||
public Color AdditionalColor { get; private set; }
|
||
/// <summary>
|
||
/// Признак (опция) "рогов"
|
||
/// </summary>
|
||
public bool Pantograph { get; private set; }
|
||
/// <summary>
|
||
/// Признак (опция) наличия отсека под батареи
|
||
/// </summary>
|
||
public bool BatteryStorage { get; private set; }
|
||
/// <summary>
|
||
/// Шаг перемещения Локомотива
|
||
/// </summary>
|
||
public double Step => Speed * 100 / Weight;
|
||
/// <summary>
|
||
/// Инициализация полей объекта-класса ЭлектроЛокомотива
|
||
/// </summary>
|
||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||
/// <param name="pantograph">Признак "рогов"</param>
|
||
/// <param name="batteryStorage">Признак наличия отсека под батареи</param>
|
||
/// ------------------------------------------------------------------------------
|
||
/// Переписать!!!!!!!!!
|
||
/// САМИМ ТО ЧТО СНИЗУ!!!!!!!!!!!!!!!!!!
|
||
public EntityElectricLocomotive(int speed, double weight, Color bodyColor, Color additionalColor, bool pantograph
|
||
, bool batteryStorage) : base(speed, weight, bodyColor)
|
||
{
|
||
AdditionalColor = additionalColor;
|
||
Pantograph = pantograph;
|
||
BatteryStorage = batteryStorage;
|
||
}
|
||
|
||
/// <summary>
|
||
/// Получение строк со значениями свойств объекта класса-сущности
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public override string[] GetStringRepresentation()
|
||
{
|
||
return new string[] { nameof(EntityElectricLocomotive), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name, Pantograph.ToString(), BatteryStorage.ToString() };
|
||
}
|
||
|
||
/// <summary>
|
||
/// Создание объекта из массива строк
|
||
/// </summary>
|
||
/// <param name="strs"></param>
|
||
/// <returns></returns>
|
||
public static EntityElectricLocomotive? CreateEntityElectricLocomotive(string[] strs)
|
||
{
|
||
if (strs.Length != 7 || strs[0] != nameof(EntityElectricLocomotive))
|
||
{
|
||
return null;
|
||
}
|
||
return new EntityElectricLocomotive(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
|
||
}
|
||
|
||
|
||
internal void setAdditionalColor(Color additionalColor)
|
||
{
|
||
AdditionalColor = additionalColor;
|
||
}
|
||
|
||
}
|
||
}
|