PIbd-21_KozyrevSS_GasolineT.../Lab/CarsGenericStorage.cs
2023-10-18 12:28:36 +04:00

48 lines
1.4 KiB
C#

using Lab.DrawningObjects;
using Lab.MovementStrategy;
using Lab.Generics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lab.Generics
{
internal class CarsGenericStorage
{
readonly Dictionary<string, CarsGenericCollection<DrawTanker, DrawingObjectTanker>> _carStorages;
public List<string> Keys => _carStorages.Keys.ToList();
private readonly int _pictureWidth;
private readonly int _pictureHeight;
public CarsGenericStorage(int pictureWidth, int pictureHeight)
{
_carStorages = new Dictionary<string, CarsGenericCollection<DrawTanker, DrawingObjectTanker>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
public void AddSet(string name)
{
if (_carStorages.ContainsKey(name)) return;
_carStorages[name] = new CarsGenericCollection<DrawTanker, DrawingObjectTanker>(_pictureWidth, _pictureHeight);
}
public void DelSet(string name)
{
if (!_carStorages.ContainsKey(name)) return;
_carStorages.Remove(name);
}
public CarsGenericCollection<DrawTanker, DrawingObjectTanker>?
this[string ind]
{
get
{
if (_carStorages.ContainsKey(ind)) return _carStorages[ind];
return null;
}
}
}
}