From a9f39a20a9193d884b8c0d551dd526af5a701bc1 Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Sat, 19 Nov 2022 14:06:39 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B=20=D0=B2=20?= =?UTF-8?q?MapWithSetLocomotivesGeneric?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawningObjectLocomotive.java | 4 ++++ MapWithSetLocomotivesGeneric.java | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) 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)); + } + } + }