LabWork_04 #7

Closed
maxnes3 wants to merge 7 commits from LabWork_04 into LabWork_03
Showing only changes of commit 783652be17 - Show all commits

View File

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WarmlyShip
{
internal class MapsCollection
{
readonly Dictionary<string, MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>> _mapStorages;
public List<string> Keys => _mapStorages.Keys.ToList();
private readonly int _pictureWidth;
private readonly int _pictureHeight;
public MapsCollection(int pictureWidth, int pictureHeight)
{
_mapStorages = new Dictionary<string, MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
public void AddMap(string name, AbstractMap map)
{
_mapStorages.Add(name, new MapWithSetShipGeneric<DrawningObjectShip, AbstractMap>(_pictureWidth, _pictureHeight, map));
}
public void DelMap(string name)
{
_mapStorages.Remove(name);
}
public MapWithSetShipGeneric<DrawningObjectShip, AbstractMap> this[string ind]
{
get
{
foreach (var map in _mapStorages)
{
if(map.Key == ind) return map.Value;
}
return null;
}
}
}
}