From 1176a9d600e224aa2b0e7de7b40823ea747a5eee Mon Sep 17 00:00:00 2001 From: Semka Date: Sun, 13 Nov 2022 22:01:51 +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 --- .../GasolineTanker/MapsCollection.cs | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 GasolineTanker/GasolineTanker/MapsCollection.cs diff --git a/GasolineTanker/GasolineTanker/MapsCollection.cs b/GasolineTanker/GasolineTanker/MapsCollection.cs new file mode 100644 index 0000000..86230d8 --- /dev/null +++ b/GasolineTanker/GasolineTanker/MapsCollection.cs @@ -0,0 +1,45 @@ +using System.Linq; +using System.Xml.Linq; + +namespace GasolineTanker +{ + 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 MapWithSetTankersGeneric + (_pictureWidth, _pictureHeight, map)); + } + } + public void DelMap(string name) + { + if (_mapStorages.ContainsKey(name)) + _mapStorages.Remove(name); + } + public MapWithSetTankersGeneric this[string ind] + { + get + { + if (_mapStorages.ContainsKey(ind)) + return _mapStorages[ind]; + else + return null; + } + } + } +}