From 783652be175ba190212be1261f57fb81122a422e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Sat, 29 Oct 2022 23:14:46 +0400 Subject: [PATCH] =?UTF-8?q?2=20=D1=8D=D1=82=D0=B0=D0=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/MapsCollection.cs | 49 +++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 WarmlyShip/WarmlyShip/MapsCollection.cs diff --git a/WarmlyShip/WarmlyShip/MapsCollection.cs b/WarmlyShip/WarmlyShip/MapsCollection.cs new file mode 100644 index 0000000..13d66c0 --- /dev/null +++ b/WarmlyShip/WarmlyShip/MapsCollection.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace WarmlyShip +{ + 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) + { + _mapStorages.Add(name, new MapWithSetShipGeneric(_pictureWidth, _pictureHeight, map)); + } + public void DelMap(string name) + { + _mapStorages.Remove(name); + } + + public MapWithSetShipGeneric this[string ind] + { + get + { + foreach (var map in _mapStorages) + { + if(map.Key == ind) return map.Value; + } + return null; + } + } + + } +}