Четвертая лабораторная работа. Правка метода вставки.

This commit is contained in:
Андрей Абазов 2022-10-18 13:15:50 +04:00
parent aa4ca53f3f
commit 38d73a94a7

View File

@ -36,7 +36,7 @@ namespace AirBomber
/// <returns></returns> /// <returns></returns>
public int Insert(T airBomber) public int Insert(T airBomber)
{ {
if (_places.Count >= _maxCount) return -1; if (_places.Count + 1 >= _maxCount) return -1;
_places.Insert(0, airBomber); _places.Insert(0, airBomber);
return 0; return 0;
} }
@ -49,7 +49,7 @@ namespace AirBomber
public int Insert(T airBomber, int position) public int Insert(T airBomber, int position)
{ {
if (position < 0 || position >= _maxCount) return -1; if (position < 0 || position >= _maxCount) return -1;
if (_places.Count >= _maxCount) return -1; if (_places.Count + 1 >= _maxCount) return -1;
_places.Insert(position, airBomber); _places.Insert(position, airBomber);
return position; return position;
} }