From 97bc6e1c6635421b5390802c4f8000262668d524 Mon Sep 17 00:00:00 2001 From: "A.Novopoltsev" Date: Fri, 16 Dec 2022 23:23:15 +0300 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 --- Warship/Warship/MapsCollection.cs | 55 +++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Warship/Warship/MapsCollection.cs diff --git a/Warship/Warship/MapsCollection.cs b/Warship/Warship/MapsCollection.cs new file mode 100644 index 0000000..7eae226 --- /dev/null +++ b/Warship/Warship/MapsCollection.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Warship +{ + 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)) + { + MessageBox.Show("Карта уже существует"); + return; + } + else + { + _mapStorages.Add(name, new MapWithSetWarshipsGeneric(_pictureWidth, _pictureHeight, map)); + } + } + + public void DelMap(string name) + { + + _mapStorages.Remove(name); + + } + + public MapWithSetWarshipsGeneric this[string ind] + { + get + { + if (_mapStorages.ContainsKey(ind)) + return _mapStorages[ind]; + return null; + } + } + } +}