From 58eb69ead555beed245d175a0b3c219288d1a2c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=B9=D0=B4=D0=B0=D1=80?= Date: Wed, 9 Nov 2022 15:11:51 +0400 Subject: [PATCH] =?UTF-8?q?=D0=AD=D1=82=D0=B0=D0=BF=202.=20=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 --- Battleship/Battleship/MapsCollection.cs | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Battleship/Battleship/MapsCollection.cs diff --git a/Battleship/Battleship/MapsCollection.cs b/Battleship/Battleship/MapsCollection.cs new file mode 100644 index 0000000..8f176d2 --- /dev/null +++ b/Battleship/Battleship/MapsCollection.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Battleship +{ + internal class MapsCollection + { + readonly Dictionary> _mapStorage; + + public List Keys => _mapStorage.Keys.ToList(); + + private readonly int _pictureWidth; + + private readonly int _pictureHeight; + + public MapsCollection(int pictureWidth, int pictureHeight) + { + _mapStorage = new Dictionary>(); + _pictureWidth = pictureWidth; + _pictureHeight = pictureHeight; + } + public void AddMap(string name, AbstractMap map) + { + var NewElem = new MapWithSetBattleshipGeneric( + _pictureWidth, _pictureHeight, map); + _mapStorage.Add(name, NewElem); + } + public void DelMap(string name) + { + _mapStorage.Remove(name); + } + public MapWithSetBattleshipGeneric this[string ind] + { + get + { + return _mapStorage[ind]; + } + } + } +} \ No newline at end of file