From b61cfee9fb575a9785c8f9bc709724bb1697b283 Mon Sep 17 00:00:00 2001 From: Pavel_Sorokin Date: Wed, 19 Oct 2022 17:25:11 +0400 Subject: [PATCH] =?UTF-8?q?=D0=AD=D1=82=D0=B0=D0=BF=202.=20=D0=9A=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D1=81=20MapsCollection.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Liner/Liner/MapsCollection.cs | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Liner/Liner/MapsCollection.cs diff --git a/Liner/Liner/MapsCollection.cs b/Liner/Liner/MapsCollection.cs new file mode 100644 index 0000000..5dd14d7 --- /dev/null +++ b/Liner/Liner/MapsCollection.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Liner +{ + internal class MapsCollection + { + readonly Dictionary> _mapStorages; + public List Keys => _mapStorages.Keys.ToList(); + private readonly int _pictureWidth; + private readonly int _pictureHeight; + public MapsCollection(int pictureWidth, int pictureHeight) + { + _mapStorages = new Dictionary>(); + _pictureWidth = pictureWidth; + _pictureHeight = pictureHeight; + } + public void AddMap(string name, AbstractMap map) + { + if (!_mapStorages.ContainsKey(name)) + { + _mapStorages.Add(name, new MapWithSetShipsGeneric(_pictureWidth, _pictureHeight, map)); + } + } + public void DelMap(string name) + { + if (_mapStorages.ContainsKey(name)) _mapStorages.Remove(name); + } + public MapWithSetShipsGeneric this[string ind] + { + get + { + if (_mapStorages.ContainsKey(ind)) + { + return _mapStorages[ind]; + } + return null; + } + } + } +}