Этап 2. Класс MapsCollection
This commit is contained in:
parent
a87accfcb1
commit
1176a9d600
45
GasolineTanker/GasolineTanker/MapsCollection.cs
Normal file
45
GasolineTanker/GasolineTanker/MapsCollection.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace GasolineTanker
|
||||||
|
{
|
||||||
|
internal class MapsCollection
|
||||||
|
{
|
||||||
|
readonly Dictionary<string, MapWithSetTankersGeneric<DrawningObjectTanker, 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, MapWithSetTankersGeneric<DrawningObjectTanker, AbstractMap>>();
|
||||||
|
_pictureWidth = pictureWidth;
|
||||||
|
_pictureHeight = pictureHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddMap(string name, AbstractMap map)
|
||||||
|
{
|
||||||
|
if (!_mapStorages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
_mapStorages.Add(name, new MapWithSetTankersGeneric<DrawningObjectTanker, AbstractMap>
|
||||||
|
(_pictureWidth, _pictureHeight, map));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DelMap(string name)
|
||||||
|
{
|
||||||
|
if (_mapStorages.ContainsKey(name))
|
||||||
|
_mapStorages.Remove(name);
|
||||||
|
}
|
||||||
|
public MapWithSetTankersGeneric<DrawningObjectTanker, AbstractMap> this[string ind]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_mapStorages.ContainsKey(ind))
|
||||||
|
return _mapStorages[ind];
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user