fix bugs
This commit is contained in:
parent
d43966d9eb
commit
7e4fd641e7
@ -30,13 +30,13 @@ namespace AirFighter
|
|||||||
public int Insert(T car)
|
public int Insert(T car)
|
||||||
{
|
{
|
||||||
// TODO вставка в начало набора
|
// TODO вставка в начало набора
|
||||||
if (_places.Count == _maxCount) return -1;
|
if (_places.Count == _maxCount) throw new StorageOverflowException(_maxCount);
|
||||||
_places.Insert(0, car);
|
_places.Insert(0, car);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
public int Insert(T car, int position)
|
public int Insert(T car, int position)
|
||||||
{
|
{
|
||||||
if (_places.Count == _maxCount) throw new StorageOverflowException(_maxCount); ;
|
if (_places.Count == _maxCount) throw new StorageOverflowException(_maxCount);
|
||||||
_places.Insert(position, car);
|
_places.Insert(position, car);
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ namespace AirFighter
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public T Remove(int position)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
if(position >= _maxCount) throw new AircraftNotFoundException(position);
|
if(position >= _maxCount || position >= _places.Count) throw new AircraftNotFoundException(position);
|
||||||
|
|
||||||
T res = _places[position];
|
T res = _places[position];
|
||||||
_places.Remove(res);
|
_places.Remove(res);
|
||||||
|
Loading…
Reference in New Issue
Block a user