Kadyrov A.F. LabWork04 #4

Closed
NAP wants to merge 3 commits from LabWork04 into LabWork03
Showing only changes of commit 58eb69ead5 - Show all commits

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);
Review

Нет проверки, что такой ключ уже есть в словаре

Нет проверки, что такой ключ уже есть в словаре
}
public void DelMap(string name)
{
_mapStorage.Remove(name);
}
public MapWithSetBattleshipGeneric<DrawningObjectBattleship, AbstractMap> this[string ind]
{
get
{
return _mapStorage[ind];
Review

Нет проверки, что такой ключ уже есть в словаре

Нет проверки, что такой ключ уже есть в словаре
}
}
}
}