This commit is contained in:
Мельников Игорь 2022-10-13 15:09:19 +04:00
parent 55e54327c6
commit 38ed0c2a42

View File

@ -27,6 +27,18 @@
public bool Insert(T locomotive)
{
// TODO проверка на наличие свободных мест
T testLocomotive = _places[0];
for (int i = 0; i < Count; i++)
{
if (_places[i] == null)
{
testLocomotive = _places[i];
}
}
if (testLocomotive != null)
{
return false;
}
for (int i = Count - 2; i >= 0; i--)
{
_places[i + 1] = _places[i];