diff --git a/AirPlaneWithRadar/AirPlaneWithRadar/SetPlaneGeneric.cs b/AirPlaneWithRadar/AirPlaneWithRadar/SetPlaneGeneric.cs index 45b9dc2..291aa24 100644 --- a/AirPlaneWithRadar/AirPlaneWithRadar/SetPlaneGeneric.cs +++ b/AirPlaneWithRadar/AirPlaneWithRadar/SetPlaneGeneric.cs @@ -20,17 +20,13 @@ namespace AirPlaneWithRadar } public int Insert(T plain) { - if (_places.Count == _maxCount) - { - return -1; - } - _places.Insert(0, plain); - + + Insert(plain, 0); return _places.Count; } 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; else if (plain == null) return -1;