Этап 2. Класс MapsCollection

This commit is contained in:
Nap 2022-11-09 15:11:51 +04:00
parent 9811cd100e
commit 58eb69ead5

View File

@ -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<string, MapWithSetBattleshipGeneric<DrawningObjectBattleship, AbstractMap>> _mapStorage;
public List<string> Keys => _mapStorage.Keys.ToList();
private readonly int _pictureWidth;
private readonly int _pictureHeight;
public MapsCollection(int pictureWidth, int pictureHeight)
{
_mapStorage = new Dictionary<string, MapWithSetBattleshipGeneric<DrawningObjectBattleship, AbstractMap>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
public void AddMap(string name, AbstractMap map)
{
var NewElem = new MapWithSetBattleshipGeneric<DrawningObjectBattleship, AbstractMap>(
_pictureWidth, _pictureHeight, map);
_mapStorage.Add(name, NewElem);
}
public void DelMap(string name)
{
_mapStorage.Remove(name);
}
public MapWithSetBattleshipGeneric<DrawningObjectBattleship, AbstractMap> this[string ind]
{
get
{
return _mapStorage[ind];
}
}
}
}