Готовая 7 лаба

This commit is contained in:
platoff aeeee 2023-12-25 10:47:13 +04:00
parent 5c23c80066
commit e447b0db60

View File

@ -40,8 +40,8 @@ namespace Tank.Generics
public bool Remove(int position) public bool Remove(int position)
{ {
if (position < 0 || position > _maxCount) if (position < 0 || position > _maxCount || position >= Count)
return false; throw new TankNotFoundException(position);
_places.RemoveAt(position); _places.RemoveAt(position);
return true; return true;
} }
@ -49,15 +49,13 @@ namespace Tank.Generics
{ {
get get
{ {
if (position < 0 || position > _maxCount) if(position < 0 || position >= Count)
{
return null; return null;
}
return _places[position]; return _places[position];
} }
set set
{ {
if (position < 0 || position > _maxCount) if (position < 0 || position > _maxCount || Count == _maxCount)
{ {
return; return;
} }