Исправление метода вставки в классе SetPlaneGeneric

This commit is contained in:
Володя 2022-11-11 11:05:26 +03:00
parent 412fab79a2
commit 98421f8d63

View File

@ -20,17 +20,13 @@ namespace AirPlaneWithRadar
} }
public int Insert(T plain) public int Insert(T plain)
{ {
if (_places.Count == _maxCount)
{ Insert(plain, 0);
return -1;
}
_places.Insert(0, plain);
return _places.Count; return _places.Count;
} }
public int Insert(T plain, int position) public int Insert(T plain, int position)
{ {
if (position < 0 || _places.Count < position||position > _maxCount) if (position < 0 || _places.Count < position||position > _maxCount || _places.Count == _maxCount)
return -1; return -1;
else if (plain == null) else if (plain == null)
return -1; return -1;