diff --git a/ProjectDumpTruck/ProjectDumpTruck/CollectionGenericObject/Autopark.cs b/ProjectDumpTruck/ProjectDumpTruck/CollectionGenericObject/Autopark.cs index f8f0694..5f237b6 100644 --- a/ProjectDumpTruck/ProjectDumpTruck/CollectionGenericObject/Autopark.cs +++ b/ProjectDumpTruck/ProjectDumpTruck/CollectionGenericObject/Autopark.cs @@ -61,30 +61,6 @@ public class Autopark : AbstractCompany } } - //protected override void SetObjectsPosition() - //{ - // int nowWidth = 0; - // int nowHeight = 0; - - // for (int i = 0; i < (_collection?.Count ?? 0); i++) - // { - // if (nowHeight > _pictureHeight / _placeSizeHeight) - // { - // return; - // } - // if (_collection?.Get(i) != null) - // { - // _collection?.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight); - // _collection?.Get(i)?.SetPosition(_placeSizeWidth * nowWidth + 30, nowHeight * _placeSizeHeight * 2 + 20); - // } - - // if (nowWidth < _pictureWidth / _placeSizeWidth - 1) nowWidth++; - // else - // { - // nowWidth = 0; - // nowHeight++; - // } - // } - //} + } diff --git a/ProjectDumpTruck/ProjectDumpTruck/CollectionGenericObject/CollectionType.cs b/ProjectDumpTruck/ProjectDumpTruck/CollectionGenericObject/CollectionType.cs new file mode 100644 index 0000000..16e1df4 --- /dev/null +++ b/ProjectDumpTruck/ProjectDumpTruck/CollectionGenericObject/CollectionType.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectDumpTruck.CollectionGenericObject; + +public enum CollectionType +{ + None = 0, + + Massive = 1, + + List = 2 +} diff --git a/ProjectDumpTruck/ProjectDumpTruck/CollectionGenericObject/ListGenericObjects.cs b/ProjectDumpTruck/ProjectDumpTruck/CollectionGenericObject/ListGenericObjects.cs new file mode 100644 index 0000000..1b5d6b5 --- /dev/null +++ b/ProjectDumpTruck/ProjectDumpTruck/CollectionGenericObject/ListGenericObjects.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectDumpTruck.CollectionGenericObject; + +public class ListGenericObjects : ICollectionGenericObject + where T : class +{ + + private readonly List _collection; + + private int _maxCount; + + public int Count => _collection.Count; + + public int SetMaxCount { set { if (value > 0) { _maxCount = value; } } } + + public ListGenericObjects() + { + _collection = new(); + } + + public T? Get(int position) + { + if (position<0||position>=Count) return null; + return _collection[position]; + } + + public int Insert(T obj) + { + if (Count + 1 > _maxCount) + { + return -1; + } + _collection.Add(obj); + return 1; + } + + public int Insert(T obj, int position) + { + if (position < 0 || position > Count || Count + 1 > _maxCount) + { + return -1; + } + _collection.Insert(position, obj); + return 1; + } + + public T? Remove(int position) + { + if (position < 0 || position > Count) + { + return null; + } + T? obj = _collection[position]; + _collection.RemoveAt(position); + return obj; + } +} diff --git a/ProjectDumpTruck/ProjectDumpTruck/CollectionGenericObject/StorageCollection.cs b/ProjectDumpTruck/ProjectDumpTruck/CollectionGenericObject/StorageCollection.cs new file mode 100644 index 0000000..e2d8464 --- /dev/null +++ b/ProjectDumpTruck/ProjectDumpTruck/CollectionGenericObject/StorageCollection.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectDumpTruck.CollectionGenericObject; + +public class StorageCollection + where T : class +{ + + private Dictionary> _storages; + + public ListKeys => _storages.Keys.ToList(); +}