diff --git a/SelfPropelledArtilleryUnit/MapsCollection.cs b/SelfPropelledArtilleryUnit/MapsCollection.cs new file mode 100644 index 0000000..cdd47ac --- /dev/null +++ b/SelfPropelledArtilleryUnit/MapsCollection.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Artilleries +{ + internal class MapsCollection + { + readonly Dictionary> _mapsStorage; + public List Keys => _mapsStorage.Keys.ToList(); + + private readonly int _pictureWidth; + private readonly int _pictureHeight; + + public MapsCollection(int pictureWidth, int pictureHeight) + { + _mapsStorage = new Dictionary>(); + _pictureWidth = pictureWidth; + _pictureHeight = pictureHeight; + } + + public void AddMap(string name, AbstractMap map) + { + if (!_mapsStorage.ContainsKey(name)) + { + _mapsStorage.Add(name, new MapWithSetArtilleriesGeneric(_pictureWidth, _pictureHeight, map)); + } + } + + public void DelMap(string name) + { + if (_mapsStorage.ContainsKey(name)) + { + _mapsStorage.Remove(name); + } + } + + public MapWithSetArtilleriesGeneric this[string index] + { + get + { + return _mapsStorage.ContainsKey(index) ? _mapsStorage[index] : null; + } + } + } +}