diff --git a/WarmlyShip/WarmlyShip/DrawningObjectShip.cs b/WarmlyShip/WarmlyShip/DrawningObjectShip.cs index e9c2b8a..f0da2a3 100644 --- a/WarmlyShip/WarmlyShip/DrawningObjectShip.cs +++ b/WarmlyShip/WarmlyShip/DrawningObjectShip.cs @@ -36,5 +36,9 @@ namespace WarmlyShip { _warmlyShip?.SetPosition(x, y, width, height); } + + public string GetInfo() => _warmlyShip?.GetDataForSave(); + + public static IDrawningObject Create(string data) => new DrawningObjectShip(data.CreateDrawningShip()); } } diff --git a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs index 79878fb..165ec36 100644 --- a/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs +++ b/WarmlyShip/WarmlyShip/EntityWarmlyShip.cs @@ -21,5 +21,11 @@ namespace WarmlyShip Weight = weight <= 0 ? random.Next(1000, 2000) : weight; BodyColor = bodyColor; } + + public static EntityWarmlyShip Creator(string data) + { + string[] strs = data.Split(':'); + return new EntityWarmlyShip(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2])); + } } } diff --git a/WarmlyShip/WarmlyShip/ExtentionShip.cs b/WarmlyShip/WarmlyShip/ExtentionShip.cs index 84c237c..bbb188d 100644 --- a/WarmlyShip/WarmlyShip/ExtentionShip.cs +++ b/WarmlyShip/WarmlyShip/ExtentionShip.cs @@ -11,7 +11,7 @@ namespace WarmlyShip private static readonly char _separatorForObject = ':'; - public static DrawingWarmlyShip CreateDrawningCar(this string info) + public static DrawingWarmlyShip CreateDrawningShip(this string info) { string[] strs = info.Split(_separatorForObject); if (strs.Length == 3) diff --git a/WarmlyShip/WarmlyShip/IDrawningObject.cs b/WarmlyShip/WarmlyShip/IDrawningObject.cs index a732b2c..94af911 100644 --- a/WarmlyShip/WarmlyShip/IDrawningObject.cs +++ b/WarmlyShip/WarmlyShip/IDrawningObject.cs @@ -13,5 +13,7 @@ namespace WarmlyShip void MoveObject(Direction direction); void DrawningObject(Graphics g); (float Left, float Right, float Top, float Bottom) GetCurrentPosition(); + + string GetInfo(); } }