Added exceptions to SetArtilleriesGeneric
This commit is contained in:
parent
bbb24c454f
commit
8d85818dae
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user