using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Artilleries { internal class SetArtilleriesGeneric where T : class { private readonly T[] _places; public int Count => _places.Length; public SetArtilleriesGeneric(int count) { _places = new T[count]; } public bool Insert(T artillery) { return Insert(artillery, 0); } public bool Insert(T artillery, int position) { if (position < 0 || position >= Count) { return false; } _places[position] = artillery; return true; // TODO } public bool Remove(int position) { if (position < 0 || position >= Count || _places[position] == null) { return false; } _places[position] = null; return true; } public T Get(int position) { if (position < 0 || position >= Count) { return null; } return _places[position]; } } }