From ce21b5e68f5f73f2d3ce9e66c4636919d77f4a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Fri, 11 Nov 2022 18:57:16 +0400 Subject: [PATCH] 1111 --- WarmlyShip/WarmlyShip/DrawningObjectShip.cs | 4 ++++ WarmlyShip/WarmlyShip/EntityWarmlyShip.cs | 6 ++++++ WarmlyShip/WarmlyShip/ExtentionShip.cs | 2 +- WarmlyShip/WarmlyShip/IDrawningObject.cs | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) 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(); } }