2024-04-11 11:18:53 +04:00
|
|
|
|
namespace ProjectBus.Entities;
|
2024-02-29 10:45:00 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Класс-сущность "Автобус"
|
|
|
|
|
/// </summary>
|
2024-04-11 11:18:53 +04:00
|
|
|
|
public class EntityBus : EntitySimpleBus
|
2024-02-29 10:45:00 +04:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Дополнительный цвет (для опциональных элементов)
|
|
|
|
|
/// </summary>
|
2024-04-11 11:18:53 +04:00
|
|
|
|
///
|
2024-02-29 10:45:00 +04:00
|
|
|
|
public Color AdditionalColor { get; private set; }
|
2024-05-22 22:22:59 +04:00
|
|
|
|
public void setAdditionalColor(Color color)
|
|
|
|
|
{
|
|
|
|
|
AdditionalColor = color;
|
|
|
|
|
}
|
2024-02-29 10:45:00 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-04-11 11:18:53 +04:00
|
|
|
|
/// Признак (опция) наличия дополнительного отсека
|
2024-02-29 10:45:00 +04:00
|
|
|
|
/// </summary>
|
|
|
|
|
public bool AdditionalCompartment { get; private set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-04-11 11:18:53 +04:00
|
|
|
|
/// Признак (опция) наличия гармошки
|
2024-02-29 10:45:00 +04:00
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Accordion { get; private set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Инициализация полей объекта-класса спортивного автомобиля
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="speed">Скорость</param>
|
|
|
|
|
/// <param name="weight">Вес автобуса</param>
|
|
|
|
|
/// <param name="bodyColor">Основной цвет</param>
|
|
|
|
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
|
|
|
|
/// <param name="additionalCompartment">Признак наличия дополнительного отсека</param>
|
|
|
|
|
/// <param name="accordion">Признак наличия гармошки</param>
|
2024-04-11 11:18:53 +04:00
|
|
|
|
public EntityBus(int speed, double weight, Color bodyColor, Color additionalColor, bool additionalCompartment, bool accordion) : base(speed, weight, bodyColor)
|
2024-02-29 10:45:00 +04:00
|
|
|
|
{
|
|
|
|
|
AdditionalColor = additionalColor;
|
|
|
|
|
AdditionalCompartment = additionalCompartment;
|
|
|
|
|
Accordion = accordion;
|
|
|
|
|
}
|
2024-05-23 08:50:46 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получение строк со значениями свойств объекта класса-сущности
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public override string[] GetStringRepresentation()
|
|
|
|
|
{
|
|
|
|
|
return new[]
|
|
|
|
|
{
|
|
|
|
|
nameof(EntityBus), Speed.ToString(),
|
|
|
|
|
Weight.ToString(), BodyColor.Name, AdditionalColor.Name, AdditionalCompartment.ToString(), Accordion.ToString()
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание объекта из массива строк
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="strs"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static EntitySimpleBus? CreateEntityBus(string[] strs)
|
|
|
|
|
{
|
|
|
|
|
if (strs.Length != 7 || strs[0] != nameof(EntityBus))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new EntityBus(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]), Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[5]));
|
|
|
|
|
}
|
|
|
|
|
}
|