diff --git a/ProjectStormtrooper/ProjectStormtrooper/ExtensionDrawingPlane.cs b/ProjectStormtrooper/ProjectStormtrooper/ExtensionDrawingPlane.cs
new file mode 100644
index 0000000..ee04ab0
--- /dev/null
+++ b/ProjectStormtrooper/ProjectStormtrooper/ExtensionDrawingPlane.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectStormtrooper
+{
+ public static class ExtensionDrawingPlane
+ {
+ ///
+ /// Создание объекта из строки
+ ///
+ public static DrawingPlane? CreateDrawingPlane(this string info, char separatorForObject, int width, int height)
+ {
+ string[] strs = info.Split(separatorForObject);
+ if (strs.Length == 3)
+ {
+ return new DrawingPlane(Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), Color.FromName(strs[2]), width, height);
+ }
+ if (strs.Length == 7)
+ {
+ return new DrawingStormtrooper(
+ Convert.ToInt32(strs[0]),
+ Convert.ToInt32(strs[1]),
+ Color.FromName(strs[2]),
+ Color.FromName(strs[3]),
+ Convert.ToBoolean(strs[4]),
+ Convert.ToBoolean(strs[5]),
+ width,
+ height);
+ }
+ return null;
+ }
+ ///
+ /// Получение данных для сохранения в файл
+ ///
+ public static string GetDataForSave(this DrawingPlane drawningPlane, char separatorForObject)
+ {
+ var plane = drawningPlane.EntityPlane;
+ if (plane == null)
+ {
+ return string.Empty;
+ }
+ var str = $"{plane.Speed}{separatorForObject}{plane.Weight}{separatorForObject}{plane.BodyColor.Name}";
+ if (plane is not EntityStormtrooper stormtrooper)
+ {
+ return str;
+ }
+ return $"{str}{separatorForObject}{stormtrooper.AdditionalColor.Name}{separatorForObject}{stormtrooper.Rockets}{separatorForObject}{stormtrooper.Bombs}";
+ }
+ }
+}
diff --git a/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericCollection.cs b/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericCollection.cs
index 3a7f871..a2afcc5 100644
--- a/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericCollection.cs
+++ b/ProjectStormtrooper/ProjectStormtrooper/PlanesGenericCollection.cs
@@ -138,5 +138,9 @@ namespace ProjectStormtrooper
i++;
}
}
+ ///
+ /// Получение объектов коллекции
+ ///
+ public IEnumerable GetPlanes => _collection.GetPlanes();
}
}