2024-04-11 11:18:53 +04:00
|
|
|
|
namespace ProjectBus.Entities;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Класс-сущность "Автобус"
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
|
|
public class EntitySimpleBus
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Скорость
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Speed { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Вес
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double Weight { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Основной цвет
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Color BodyColor { get; private set; }
|
2024-05-24 01:18:13 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Основной цвет
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="color"></param>
|
|
|
|
|
public void SetBodyColor(Color color)
|
|
|
|
|
{
|
|
|
|
|
BodyColor = color;
|
|
|
|
|
}
|
2024-04-11 11:18:53 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Шаг перемещения автомобиля
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double Step => Speed * 100 / Weight;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Конструктор сущности
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="speed">Скорость</param>
|
|
|
|
|
/// <param name="weight">Вес автобуса</param>
|
|
|
|
|
/// <param name="bodyColor">Основной цвет</param>
|
|
|
|
|
public EntitySimpleBus(int speed, double weight, Color bodyColor)
|
|
|
|
|
{
|
|
|
|
|
Speed = speed;
|
|
|
|
|
Weight = weight;
|
|
|
|
|
BodyColor = bodyColor;
|
|
|
|
|
}
|
2024-05-23 08:50:46 +04:00
|
|
|
|
|
|
|
|
|
// <summary>
|
|
|
|
|
/// Получение строк со значениями свойств объекта класса-сущности
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public virtual string[] GetStringRepresentation()
|
|
|
|
|
{
|
|
|
|
|
return new[] { nameof(EntitySimpleBus), Speed.ToString(), Weight.ToString(), BodyColor.Name };
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание объекта из массива строк
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="strs"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static EntitySimpleBus? CreateEntitySimpleBus(string[] strs)
|
|
|
|
|
{
|
|
|
|
|
if (strs.Length != 4 || strs[0] != nameof(EntitySimpleBus))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new EntitySimpleBus(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
|
|
|
|
}
|
2024-04-11 11:18:53 +04:00
|
|
|
|
}
|