45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
namespace ProjectPlane.Entities;
|
||
public class EntityShip
|
||
{
|
||
public int Speed { get; private set; }
|
||
|
||
/// <summary>
|
||
/// Вес
|
||
/// </summary>
|
||
public double Weight { get; private set; }
|
||
|
||
/// <summary>
|
||
/// Цвет контейнеровоза
|
||
/// </summary>
|
||
public Color ShipColor { get; private set; }
|
||
|
||
public double Step => Speed * 100 / Weight;
|
||
|
||
public EntityShip(int speed, double weight, Color shipColor)
|
||
{
|
||
Speed = speed;
|
||
Weight = weight;
|
||
ShipColor = shipColor;
|
||
}
|
||
|
||
public void ShipColorChange(Color newColor)
|
||
{
|
||
ShipColor = newColor;
|
||
}
|
||
|
||
public virtual string[] GetStringRepresentation()
|
||
{
|
||
return new[] { nameof(EntityShip), Speed.ToString(), Weight.ToString(), ShipColor.Name };
|
||
}
|
||
|
||
|
||
public static EntityShip? CreateEntityShip(string[] strs)
|
||
{
|
||
if (strs.Length != 4 || strs[0] != nameof(EntityShip))
|
||
{
|
||
return null;
|
||
}
|
||
return new EntityShip(Convert.ToInt32(strs[1]), Convert.ToDouble(strs[2]), Color.FromName(strs[3]));
|
||
}
|
||
|
||
} |