diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericStorage.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericStorage.cs new file mode 100644 index 0000000..14ed5b5 --- /dev/null +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericStorage.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectTractor.DrawningObjects; +using ProjectTractor.MovementStrategy; +using ProjectTractor.Generics; + +namespace ProjectTractor +{ + /// + /// Класс для хранения коллекции + /// + internal class TractorsGenericStorage + { + /// + /// Словарь (хранилище) + /// + readonly Dictionary> _tractorStorages; + /// + /// Возвращение списка названий наборов + /// + public List Keys => _tractorStorages.Keys.ToList(); + /// + /// Ширина окна отрисовки + /// + private readonly int _pictureWidth; + /// + /// Высота окна отрисовки + /// + private readonly int _pictureHeight; + /// + /// Конструктор + /// + /// + /// + public TractorsGenericStorage(int pictureWidth, int pictureHeight) + { + _tractorStorages = new Dictionary>(); + _pictureWidth = pictureWidth; + _pictureHeight = pictureHeight; + } + /// + /// Добавление набора + /// + /// Название набора + public void AddSet(string name) + { + _tractorStorages.Add(name, + new TractorsGenericCollection(_pictureWidth, _pictureHeight)); + } + /// + /// Удаление набора + /// + /// Название набора + public void DelSet(string name) + { + if (!_tractorStorages.ContainsKey(name)) + return; + _tractorStorages.Remove(name); + } + /// + /// Доступ к набору + /// + /// + /// + public TractorsGenericCollection? + this[string ind] + { + get + { + if (_tractorStorages.ContainsKey(ind)) + return _tractorStorages[ind]; + return null; + } + } + } +}