using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AirBomber.Entities; /// /// Класс-сущность "Самолет" /// public class EntityAirPlane { /// /// Скорость /// public int Speed { get; private set; } /// /// Вес /// public double Weight { get; private set; } public void SetBodyColor(Color color) => BodyColor = color; /// /// Основной цвет /// public Color BodyColor { get; private set; } /// /// шаг перемещения /// public double Step => Speed * 100 / Weight; /// /// Конструктор сущнсоти /// /// Скорость /// Вес /// Основной цвет public EntityAirPlane(int speed, double weight, Color bodyColor) { Speed = speed; Weight = weight; BodyColor = bodyColor; } /// /// Получение строк со значениями свойств объекта класса-сущности /// /// public virtual string[] GetStringRepresentation() { return new[] { nameof(EntityAirPlane), Speed.ToString(), Weight.ToString(), BodyColor.Name }; } /// /// Создание объекта из массива строк /// /// /// public static EntityAirPlane? CreateEntityAirPlane(string[] strs) { if (strs.Length != 4 || strs[0] != nameof(EntityAirPlane)) { return null; } return new EntityAirPlane(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3])); } }