Добавлены выбросы исключений в методах добавления и удаления объектов
This commit is contained in:
parent
163355d57d
commit
c6e16a8fc1
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using ProjectStormtrooper.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -49,6 +50,10 @@ namespace ProjectStormtrooper
|
||||
/// <returns></returns>
|
||||
public int Insert(T plane, int position)
|
||||
{
|
||||
if (_places.Count == _maxCount)
|
||||
{
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
}
|
||||
// Проверка позиции
|
||||
if (position < 0 || position >= _maxCount)
|
||||
{
|
||||
@ -72,6 +77,10 @@ namespace ProjectStormtrooper
|
||||
}
|
||||
// Удаление объекта из массива, присвоив элементу массива значение null
|
||||
T? plane = _places[position];
|
||||
if (plane == null)
|
||||
{
|
||||
throw new PlaneNotFoundException(position);
|
||||
}
|
||||
_places[position] = null;
|
||||
return plane;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user