Added exceptions to SetArtilleriesGeneric

This commit is contained in:
Сергей Полевой 2022-12-05 22:12:14 +04:00
parent bbb24c454f
commit 8d85818dae

View File

@ -20,7 +20,11 @@ public class SetArtilleriesGeneric<T> {
}
public int insert(T artillery, int position) {
if (position < 0 || position > getCount() || getCount() == _maxCount) {
if (getCount() == _maxCount) {
throw new StorageOverflowException(_maxCount);
}
if (position < 0 || position > getCount()) {
return -1;
}
@ -37,6 +41,10 @@ public class SetArtilleriesGeneric<T> {
T result = _places.get(position);
if (result == null) {
throw new ArtilleryNotFoundException(position);
}
_places.remove(position);
return result;