Этап 2. Класс MapsCollection
This commit is contained in:
parent
54220c6fc7
commit
97bc6e1c66
55
Warship/Warship/MapsCollection.cs
Normal file
55
Warship/Warship/MapsCollection.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Warship
|
||||||
|
{
|
||||||
|
internal class MapsCollection
|
||||||
|
{
|
||||||
|
readonly Dictionary<string, MapWithSetWarshipsGeneric<DrawingObjectWarship, 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, MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap>>();
|
||||||
|
_pictureWidth = pictureWidth;
|
||||||
|
_pictureHeight = pictureHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddMap(string name, AbstractMap map)
|
||||||
|
{
|
||||||
|
if (_mapStorages.ContainsKey(name))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Карта уже существует");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_mapStorages.Add(name, new MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DelMap(string name)
|
||||||
|
{
|
||||||
|
|
||||||
|
_mapStorages.Remove(name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap> this[string ind]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_mapStorages.ContainsKey(ind))
|
||||||
|
return _mapStorages[ind];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user