Done
This commit is contained in:
parent
2fc3246df8
commit
7cfdcda5ed
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user