Sorokin P.V. Lab work 4 #4

Merged
eegov merged 5 commits from LabWork04 into LabWork03 2022-10-28 08:55:22 +04:00
Showing only changes of commit b61cfee9fb - Show all commits

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Liner
{
internal class MapsCollection
{
readonly Dictionary<string, MapWithSetShipsGeneric<DrawingObjectShip, 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, MapWithSetShipsGeneric<DrawingObjectShip, AbstractMap>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
public void AddMap(string name, AbstractMap map)
{
if (!_mapStorages.ContainsKey(name))
{
_mapStorages.Add(name, new MapWithSetShipsGeneric<DrawingObjectShip, AbstractMap>(_pictureWidth, _pictureHeight, map));
}
}
public void DelMap(string name)
{
if (_mapStorages.ContainsKey(name)) _mapStorages.Remove(name);
}
public MapWithSetShipsGeneric<DrawingObjectShip, AbstractMap> this[string ind]
{
get
{
if (_mapStorages.ContainsKey(ind))
{
return _mapStorages[ind];
}
return null;
}
}
}
}