Правки
This commit is contained in:
parent
ce1d47a44e
commit
4c180b71cb
@ -15,7 +15,7 @@ namespace ProjectElectricLocomotive.Generics
|
|||||||
private readonly int _pictureWidth;
|
private readonly int _pictureWidth;
|
||||||
private readonly int _pictureHeight;
|
private readonly int _pictureHeight;
|
||||||
private readonly int _placeSizeWidth = 200;
|
private readonly int _placeSizeWidth = 200;
|
||||||
private readonly int _placeSizeHeight = 120;
|
private readonly int _placeSizeHeight = 130;
|
||||||
private readonly SetGeneric<T> _collection;
|
private readonly SetGeneric<T> _collection;
|
||||||
public LocomotivesGenericCollection(int picWidth, int picHeight)
|
public LocomotivesGenericCollection(int picWidth, int picHeight)
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using ProjectElectricLocomotive.Exceptions;
|
||||||
|
|
||||||
namespace ProjectElectricLocomotive.Generics
|
namespace ProjectElectricLocomotive.Generics
|
||||||
{
|
{
|
||||||
@ -29,7 +30,13 @@ namespace ProjectElectricLocomotive.Generics
|
|||||||
|
|
||||||
public int Insert(T loco, int position)
|
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);
|
_places.Insert(position, loco);
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
@ -40,6 +47,8 @@ namespace ProjectElectricLocomotive.Generics
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
T? tmp = _places[position];
|
T? tmp = _places[position];
|
||||||
|
if (tmp == null)
|
||||||
|
throw new LocomotiveNotFoundException(position);
|
||||||
_places[position] = null;
|
_places[position] = null;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user