diff --git a/DrawningObjectLocomotive.java b/DrawningObjectLocomotive.java index 417cc14..7c46d4d 100644 --- a/DrawningObjectLocomotive.java +++ b/DrawningObjectLocomotive.java @@ -44,4 +44,8 @@ public class DrawningObjectLocomotive implements IDrawningObject { if (_locomotive == null) return null; return _locomotive.getDataForSave(); } + + public static IDrawningObject Create(String data) { + return new DrawningObjectLocomotive(DrawningLocomotive.createDrawningLocomotive(data)); + } } diff --git a/MapWithSetLocomotivesGeneric.java b/MapWithSetLocomotivesGeneric.java index a30b6c6..e7d3c43 100644 --- a/MapWithSetLocomotivesGeneric.java +++ b/MapWithSetLocomotivesGeneric.java @@ -174,4 +174,25 @@ public class MapWithSetLocomotivesGeneric } } + /// Получение данных в виде строки + public String GetData(char separatorType, char separatorData) + { + //string data = $"{_map.GetType().Name}{separatorType}"; + String data = ""+ _map.getClass() + separatorType; + for (var locomotive : _setLocomotives.GetLocomotives()) + { + data += "" + locomotive.getInfo() + separatorData; + } + return data; + } + + /// Загрузка списка из массива строк + public void LoadData(String[] records) + { + for (var rec : records) + { + _setLocomotives.Insert((T)DrawningObjectLocomotive.Create(rec)); + } + } + }