From 76c34b75aee141929cff0891755f1b1e18cc7380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=9F=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=D0=B2=D0=BE=D0=B9?= Date: Sun, 9 Oct 2022 23:21:03 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=82=D0=BE=D1=80=D0=BE=D0=B9=20=D1=8D?= =?UTF-8?q?=D1=82=D0=B0=D0=BF=20=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SelfPropelledArtilleryUnit/MapsCollection.cs | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 SelfPropelledArtilleryUnit/MapsCollection.cs 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; + } + } + } +}