PIbd-21 Belianin N.N. LabWork05 #5

Closed
Belnik wants to merge 7 commits from LabWork05 into LabWork04
2 changed files with 13 additions and 4 deletions
Showing only changes of commit 1ccff34c27 - Show all commits

View File

@ -24,20 +24,20 @@ namespace Tank
}
// Добавление объекта в набор
public bool Insert(T car)
public bool Insert(T tank)
{
return Insert(car, 0);
return Insert(tank, 0);
}
// Добавление на конкретную позицию
public bool Insert(T car, int position)
public bool Insert(T tank, int position)
{
if (position < 0 || position >= _maxCount)
return false;
if (Count >= _maxCount)
return false;
_places.Insert(0, car);
_places.Insert(0, tank);
return true;
}

View File

@ -11,28 +11,37 @@ namespace Tank
{
internal class TanksGenericStorage
{
// Словарь
readonly Dictionary<string, TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>> _tankStorages;
// Возвращение списка названий наборов
public List<string> Keys => _tankStorages.Keys.ToList();
private readonly int _pictureWidth;
private readonly int _pictureHeight;
// Конструктор
public TanksGenericStorage(int pictureWidth, int pictureHeight)
{
_tankStorages = new Dictionary<string, TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
// Добавление набора
public void AddSet(string name)
{
if (_tankStorages.ContainsKey(name)) return;
_tankStorages[name] = new TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>(_pictureWidth, _pictureHeight);
}
// Удаление набора
public void DelSet(string name)
{
if (!_tankStorages.ContainsKey(name)) return;
_tankStorages.Remove(name);
}
// Доступ к набору
public TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>?
this[string ind]
{