Корректирование проверок позиции

This commit is contained in:
ityurner02@mail.ru 2022-10-09 18:28:15 +04:00
parent 1f69ad5765
commit 40f345bcb8

View File

@ -56,7 +56,7 @@ namespace AntiAircraftGun
/// <returns></returns>
public int Insert(T antiAircraftGun, int position)
{
if (position < 0 || position > _places.Count) return -1;
if (position < 0 || position >= _places.Count) return -1;
_places.Insert(position, antiAircraftGun);
return position;
}
@ -67,7 +67,7 @@ namespace AntiAircraftGun
/// <returns></returns>
public T Remove(int position)
{
if (position < 0 || position > _places.Count) return null;
if (position < 0 || position >= _places.Count) return null;
if (_places[position] == null) return null;
T removed = _places[position];
_places.RemoveAt(position);
@ -82,12 +82,12 @@ namespace AntiAircraftGun
{
get
{
if (position < 0 || position > _places.Count) return null;
if (position < 0 || position >= _places.Count) return null;
return _places[position];
}
set
{
if (position < 0 || position > _places.Count) return;
if (position < 0 || position >= _places.Count) return;
_places.Insert(position, value);
}
}