Added MapWithSetArtilleriesGeneric serialization and deserialization

This commit is contained in:
Сергей Полевой 2022-11-20 22:41:03 +04:00
parent 8d4407de4c
commit ebc0f07204

View File

@ -124,4 +124,21 @@ public class MapWithSetArtilleriesGeneric<T extends IDrawingObject, U extends Ab
index++;
}
}
public String getData(char separatorType, char separatorData) {
StringBuilder data = new StringBuilder(String.format("%s%c", _map.getClass().getSimpleName(), separatorType));
for (var artillery : _setArtilleries.getArtilleries()) {
data.append(String.format("%s%c", artillery.getInfo(), separatorData));
}
return data.toString();
}
@SuppressWarnings("unchecked")
public void loadData(String[] records) {
for (int i = records.length - 1; i >= 0; i--) {
_setArtilleries.insert((T) DrawingObjectArtillery.create(records[i]));
}
}
}