ISEbd-12_Sinelnikova_A.V._S.../ProjectCruiser/Entities/EntityMilitaryCruiser.cs

63 lines
2.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace ProjectCruiser.Entities
{
internal class EntityMilitaryCruiser : EntityCruiser
{
/// <summary>
/// Признак (опция) наличие вертолетной площадки
/// </summary>
public bool HelicopterArea { get; private set; }
/// <summary>
/// Признак (опция) наличие шлюпок
/// </summary>
public bool Boat { get; private set; }
/// <summary>
/// Признак (опция) наличие пушки
/// </summary>
public bool Weapon { get; private set; }
/// <summary>
/// Дополнительный цвет (для опциональных элементов)
/// </summary>
public Color AdditionalColor { get; private set; }
public void setAdditionalColor(Color color)
{
AdditionalColor = color;
}
public EntityMilitaryCruiser(int speed, double weight, Color bodyColor, Color additionalColor, bool helicopterArea, bool boat, bool weapon) : base(speed, weight, bodyColor)
{
AdditionalColor = additionalColor;
HelicopterArea = helicopterArea;
Boat = boat;
Weapon = weapon;
}
/// <summary>
/// Получение строк со значениями свойств объекта класса-сущности
/// </summary>
/// <returns></returns>
public override string[] GetStringRepresentation()
{
return new[] { nameof(EntityCruiser), Speed.ToString(), Weight.ToString(), BodyColor.Name, AdditionalColor.Name,
HelicopterArea.ToString(), Boat.ToString(), Weapon.ToString() };
}
/// <summary>
/// Создание объекта из массива строк
/// </summary>
/// <param name="strs"></param>
/// <returns></returns>
public static EntityCruiser? CreateEntityMilitaryCruiser(string[] strs)
{
if (strs.Length != 8 || strs[0] != nameof(EntityCruiser))
{
return null;
}
return new EntityMilitaryCruiser(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]), Color.FromName(strs[4]),
Convert.ToBoolean(strs[5]), Convert.ToBoolean(strs[6]), Convert.ToBoolean(strs[7]));
}
}
}