Правки 4 лаб

This commit is contained in:
platoff aeeee 2023-11-08 00:26:38 +04:00
parent bda0646769
commit 270c3d7d4f
2 changed files with 3 additions and 5 deletions

View File

@ -29,9 +29,8 @@ namespace Tank.Generics
public bool Insert(T tank, int position) public bool Insert(T tank, int position)
{ {
if (position < 0 || position >= _maxCount) if (position < 0)
return false; return false;
if (Count >= _maxCount) if (Count >= _maxCount)
return false; return false;
_places.Insert(0, tank); _places.Insert(0, tank);
@ -42,8 +41,6 @@ namespace Tank.Generics
{ {
if (position < 0 || position > _maxCount) if (position < 0 || position > _maxCount)
return false; return false;
if (position >= Count)
return false;
_places.RemoveAt(position); _places.RemoveAt(position);
return true; return true;
} }

View File

@ -133,7 +133,8 @@ namespace Tank.Generics
{ {
if (tank != null) if (tank != null)
{ {
tank.SetPosition((i % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight); tank.SetPosition((i % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth,
i % (_pictureWidth / _placeSizeWidth));
tank.DrawTransport(g); tank.DrawTransport(g);
} }