72 lines
2.4 KiB
C#
72 lines
2.4 KiB
C#
|
||
using System.Net.Sockets;
|
||
|
||
namespace ProjectSeaplane.Entities;
|
||
/// <summary>
|
||
/// Класс-сущность "Гидросамолет"
|
||
/// </summary>
|
||
public class EntitySeaplane : EntityBasicSeaplane
|
||
{
|
||
|
||
/// <summary>
|
||
/// Дополнительный (для опциональных частей)
|
||
/// </summary>
|
||
public Color AdditionalColor { get; private set; }
|
||
/// <summary>
|
||
/// Тип "шасси" (0 - лодочный, 1 - поплавковый)
|
||
/// </summary>
|
||
public bool LandingGear { get; private set; }
|
||
/// <summary>
|
||
/// Признак наличия радара
|
||
/// </summary>
|
||
public bool Radar { get; private set; }
|
||
/// <summary>
|
||
/// Метод установки доп цвета
|
||
/// </summary>
|
||
/// <param name="color"></param>
|
||
public void setAdditionalColor(Color color)
|
||
{
|
||
AdditionalColor = color;
|
||
}
|
||
|
||
/// <summary>
|
||
/// Конструктор
|
||
/// </summary>
|
||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||
/// <param name="landingGear">Тип "шасси"</param>
|
||
/// <param name="radar">При</param>
|
||
|
||
public EntitySeaplane(int speed, double weight, Color bodyColor, Color additionalColor, bool landingGear, bool radar) : base(speed, weight, bodyColor)
|
||
{
|
||
|
||
AdditionalColor = additionalColor;
|
||
LandingGear = landingGear;
|
||
Radar = radar;
|
||
|
||
}
|
||
/// <summary>
|
||
/// Получение строк со значениями свойств объекта класса-сущности
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public override string[] GetStringRepresentation()
|
||
{
|
||
return new[] { nameof(EntitySeaplane), Speed.ToString(), Weight.ToString(), BodyColor.Name,
|
||
AdditionalColor.Name, LandingGear.ToString(), Radar.ToString()};
|
||
}
|
||
/// <summary>
|
||
/// Создание объекта из массива строк
|
||
/// </summary>
|
||
/// <param name="strs"></param>
|
||
/// <returns></returns>
|
||
public static EntitySeaplane? CreateEntitySeaplane(string[] strs)
|
||
{
|
||
if (strs.Length != 8 || strs[0] != nameof(EntitySeaplane))
|
||
{
|
||
return null;
|
||
}
|
||
return new EntitySeaplane(Convert.ToInt32(strs[1]),
|
||
Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]), Convert.ToBoolean(strs[5]),
|
||
Convert.ToBoolean(strs[6]));
|
||
}
|
||
}
|