From ae41ac76977f99d72a93cee562b025c3ada19144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D1=80=D0=B0=D1=82=20=D0=97=D0=B0=D1=80=D0=B3?= =?UTF-8?q?=D0=B0=D1=80=D0=BE=D0=B2?= Date: Mon, 28 Nov 2022 00:23:02 +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 --- .../DoubleDeckerBus/MapsCollection.cs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 DoubleDeckerBus/DoubleDeckerBus/MapsCollection.cs diff --git a/DoubleDeckerBus/DoubleDeckerBus/MapsCollection.cs b/DoubleDeckerBus/DoubleDeckerBus/MapsCollection.cs new file mode 100644 index 0000000..6ec4c89 --- /dev/null +++ b/DoubleDeckerBus/DoubleDeckerBus/MapsCollection.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DoubleDeckerBus +{ + 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 (Keys.Contains(name)) return; + _mapStorages.Add(name, new MapWithSetBusesGeneric(_pictureWidth, _pictureHeight, map)); + } + + public void DelMap(string name) + { + _mapStorages.Remove(name); + } + + public MapWithSetBusesGeneric this[string ind] + { + get + { + _mapStorages.TryGetValue(ind, out var result); + return result; + } + } + } +}