PIbd-21 Belianin N.N. LabWork05 #5
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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]
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user