Готовая лабораторная работа 5
This commit is contained in:
parent
1560754552
commit
1ccff34c27
@ -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)
|
if (position < 0 || position >= _maxCount)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (Count >= _maxCount)
|
if (Count >= _maxCount)
|
||||||
return false;
|
return false;
|
||||||
_places.Insert(0, car);
|
_places.Insert(0, tank);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,28 +11,37 @@ namespace Tank
|
|||||||
{
|
{
|
||||||
internal class TanksGenericStorage
|
internal class TanksGenericStorage
|
||||||
{
|
{
|
||||||
|
// Словарь
|
||||||
readonly Dictionary<string, TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>> _tankStorages;
|
readonly Dictionary<string, TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>> _tankStorages;
|
||||||
|
|
||||||
|
// Возвращение списка названий наборов
|
||||||
public List<string> Keys => _tankStorages.Keys.ToList();
|
public List<string> Keys => _tankStorages.Keys.ToList();
|
||||||
private readonly int _pictureWidth;
|
private readonly int _pictureWidth;
|
||||||
private readonly int _pictureHeight;
|
private readonly int _pictureHeight;
|
||||||
|
|
||||||
|
// Конструктор
|
||||||
public TanksGenericStorage(int pictureWidth, int pictureHeight)
|
public TanksGenericStorage(int pictureWidth, int pictureHeight)
|
||||||
{
|
{
|
||||||
_tankStorages = new Dictionary<string, TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>>();
|
_tankStorages = new Dictionary<string, TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>>();
|
||||||
_pictureWidth = pictureWidth;
|
_pictureWidth = pictureWidth;
|
||||||
_pictureHeight = pictureHeight;
|
_pictureHeight = pictureHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Добавление набора
|
||||||
public void AddSet(string name)
|
public void AddSet(string name)
|
||||||
{
|
{
|
||||||
if (_tankStorages.ContainsKey(name)) return;
|
if (_tankStorages.ContainsKey(name)) return;
|
||||||
_tankStorages[name] = new TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>(_pictureWidth, _pictureHeight);
|
_tankStorages[name] = new TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>(_pictureWidth, _pictureHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Удаление набора
|
||||||
public void DelSet(string name)
|
public void DelSet(string name)
|
||||||
{
|
{
|
||||||
if (!_tankStorages.ContainsKey(name)) return;
|
if (!_tankStorages.ContainsKey(name)) return;
|
||||||
_tankStorages.Remove(name);
|
_tankStorages.Remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Доступ к набору
|
||||||
public TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>?
|
public TanksGenericCollection<DrawArmoVehicle, DrawingObjectTank>?
|
||||||
this[string ind]
|
this[string ind]
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user