ISBd_21.GordeevI.V._LabWork_07 #11

Closed
Igor_Gordeev wants to merge 7 commits from ISBd_21.GordeevI.V._LabWork_07 into ISBd_21.GordeevI.V._LabWork_06
Showing only changes of commit 7cfdcda5ed - Show all commits

View File

@ -1,4 +1,5 @@
using System;
using ProjectElectricLocomotive.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -24,7 +25,14 @@ namespace ProjectElectricLocomotive.Generics
public int Insert(T loco, int position)
{
if (position < 0 || position >= _maxCount) return -1;
if (_places.Count >= _maxCount)
throw new StorageOverflowException(_maxCount);
if (position < 0 || position >= _maxCount)
{
return -1;
}
_places.Insert(position, loco);
return position;
}
@ -34,6 +42,8 @@ namespace ProjectElectricLocomotive.Generics
return null;
T? tmp = _places[position];
if (tmp == null)
throw new LocoNotFoundException(position);
_places[position] = null;
return tmp;
}