fixed bug with Remove

This commit is contained in:
Nikita Potapov 2022-11-26 20:57:51 +04:00
parent 62a9296290
commit 3a6d87df27
2 changed files with 2 additions and 4 deletions

View File

@ -91,7 +91,6 @@ namespace Boats
Bitmap bmp = new(_pictureWidth, _pictureHeight); Bitmap bmp = new(_pictureWidth, _pictureHeight);
Graphics g = Graphics.FromImage(bmp); Graphics g = Graphics.FromImage(bmp);
DrawBackground(g); DrawBackground(g);
Shaking();
DrawBoats(g); DrawBoats(g);
return bmp; return bmp;
} }
@ -136,8 +135,8 @@ namespace Boats
var boat = _setBoats[j]; var boat = _setBoats[j];
if (boat != null) if (boat != null)
{ {
boat = _setBoats.Remove(j);
_setBoats.Insert(boat, i); _setBoats.Insert(boat, i);
_setBoats.Remove(j);
break; break;
} }
} }

View File

@ -74,8 +74,7 @@ namespace Boats
if (Count == 0 || position < 0 || position >= _maxCount || _places[position] == null) if (Count == 0 || position < 0 || position >= _maxCount || _places[position] == null)
throw new BoatNotFoundException(position); throw new BoatNotFoundException(position);
T boat = _places[position]; T boat = _places[position];
_places.RemoveAt(position);
_places[position] = null;
return boat; return boat;
} }
public T this[int position] public T this[int position]