2024-03-23 15:11:25 +04:00
|
|
|
|
namespace ProjectAirplaneWithRadar.Entities
|
2024-02-10 18:11:15 +04:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Класс-сущность "Самолет с радаром"
|
|
|
|
|
/// </summary>
|
2024-03-23 15:11:25 +04:00
|
|
|
|
public class EntityAirplaneWithRadar : EntityAirplane
|
2024-02-10 18:11:15 +04:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Дополнительный цвет (для опциональных элементов)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Color AdditionalColor { get; private set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Признак (опция) наличия шасси
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Wheels { get; private set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-03-06 15:31:09 +04:00
|
|
|
|
/// Признак (опция) наличия радар
|
2024-02-10 18:11:15 +04:00
|
|
|
|
/// </summary>
|
2024-03-23 15:11:25 +04:00
|
|
|
|
public bool Radar { get; private set; }
|
2024-02-10 18:11:15 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-02-18 17:22:50 +04:00
|
|
|
|
/// Инициализация полей объекта-класса самолета с радаром
|
2024-02-10 18:11:15 +04:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="speed">Скорость</param>
|
2024-02-18 17:22:50 +04:00
|
|
|
|
/// <param name="weight">Вес</param>
|
2024-02-10 18:11:15 +04:00
|
|
|
|
/// <param name="bodyColor">Основной цвет</param>
|
|
|
|
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
2024-02-18 17:22:50 +04:00
|
|
|
|
/// <param name="wheels">Шасси</param>
|
2024-03-06 15:31:09 +04:00
|
|
|
|
/// <param name="radar">Радар</param>
|
2024-03-23 15:11:25 +04:00
|
|
|
|
public EntityAirplaneWithRadar(int speed, double weight, Color bodyColor, Color additionalColor, bool wheels, bool radar) : base(speed, weight, bodyColor)
|
|
|
|
|
{
|
2024-02-10 18:11:15 +04:00
|
|
|
|
AdditionalColor = additionalColor;
|
|
|
|
|
Wheels = wheels;
|
2024-03-23 15:11:25 +04:00
|
|
|
|
Radar = radar;
|
2024-02-10 18:11:15 +04:00
|
|
|
|
}
|
2024-04-13 16:42:07 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Метод передачи дополнительного цвета
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="additionalColor"></param>
|
|
|
|
|
public void SetAdditionalColor(Color additionalColor)
|
|
|
|
|
{
|
|
|
|
|
AdditionalColor = additionalColor;
|
|
|
|
|
}
|
2024-04-14 11:51:59 +04:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Переопределение метода создания объекта из массива строк
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public override string[] GetStringRepresentation()
|
|
|
|
|
{
|
|
|
|
|
return new[] { nameof(EntityAirplaneWithRadar), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name, Wheels.ToString(), Radar.ToString() };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Создание объекта из массива строк
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="strs"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static EntityAirplaneWithRadar? CreateEntityAirplaneWithRadar(string[] strs)
|
|
|
|
|
{
|
|
|
|
|
if (strs.Length != 7 || strs[0] != nameof(EntityAirplaneWithRadar))
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
return new EntityAirplaneWithRadar(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]),
|
|
|
|
|
Color.FromName(strs[3]), Color.FromName(strs[4]),
|
|
|
|
|
Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]));
|
|
|
|
|
}
|
2024-02-10 18:11:15 +04:00
|
|
|
|
}
|
|
|
|
|
}
|